-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from boyney123/feat-adding-sqs
feat: adding sqs resource to the catalog
- Loading branch information
Showing
28 changed files
with
780 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@cloudcatalog/cli": patch | ||
"@cloudcatalog/core": patch | ||
"@cloudcatalog/create-catalog": patch | ||
--- | ||
|
||
feat: adding sqs resource to the catalog |
43 changes: 43 additions & 0 deletions
43
examples/default/data/resources/sqs/PaymentProcessingQueue.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
name: PaymentProcessingQueue | ||
description: SQS Queue | ||
service: payment-service | ||
AWS: | ||
Arn: arn:aws:sqs:us-west-2:123456789123:PaymentProcessingQueue | ||
Name: PaymentProcessingQueue | ||
CreatedTimestamp: '2022-09-21T12:02:51.000Z' | ||
VisibilityTimeout: 960 | ||
MaximumMessageSize: 262144 | ||
MessageRetentionPeriod: 345600 | ||
DelaySeconds: '0' | ||
ReceiveMessageWaitTimeSeconds: '0' | ||
SqsManagedSseEnabled: 'false' | ||
QueueUrl: https://sqs.us-west-2.amazonaws.com/123456789123/PaymentProcessingQueue | ||
Account: '123456789123' | ||
Service: sqs | ||
catalog: | ||
updatedAt: '2024-01-07T16:40:30.270Z' | ||
parent: sqs | ||
path: PaymentProcessingQueue | ||
owners: | ||
- payment-team | ||
- dboyne | ||
--- | ||
|
||
|
||
## About this SQS queue | ||
|
||
The PaymentProcessingQueue acts as a mediator between the payment service and the payment processing system. When a customer initiates a payment, the details are sent to this queue, allowing for asynchronous processing. This means the payment can be processed independently of the customer's session, enhancing system resilience and user experience. | ||
|
||
#### Load Management | ||
|
||
During peak times, like sales or holiday seasons, the queue efficiently manages the increased load by holding payment requests. This prevents the payment processing service from being overwhelmed, ensuring consistent processing times and system stability. | ||
|
||
### Error Handling and Retry Mechanism | ||
|
||
In case of failures in the payment processing system, PaymentProcessingQueue can be configured to retry the payment processing after a certain interval or move the failed payment requests to a dead-letter queue for further investigation, thereby reducing the risk of lost transactions. | ||
|
||
### Send a message to the SQS queue | ||
|
||
<CLICommand>aws sqs send-message --queue-url /QueueUrl/ --message-body "Hello, this is a test message"</CLICommand> | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { | ||
SQSClient, | ||
GetQueueAttributesCommand, | ||
GetQueueUrlCommand, | ||
} from "@aws-sdk/client-sqs"; | ||
import { parse } from "@aws-sdk/util-arn-parser"; | ||
const client = new SQSClient({}); | ||
|
||
export interface Data { | ||
name?: string; | ||
description?: string; | ||
AWS: { | ||
Arn: string; | ||
Name: string; | ||
CreatedTimestamp: string | undefined; | ||
VisibilityTimeout: number | undefined; | ||
MaximumMessageSize: number | undefined; | ||
MessageRetentionPeriod: number | undefined; | ||
ReceiveMessageWaitTimeSeconds: string | undefined; | ||
DelaySeconds: string | undefined; | ||
SqsManagedSseEnabled: string | undefined; | ||
QueueUrl: string | undefined; | ||
Account: string; | ||
Service: string; | ||
}; | ||
} | ||
|
||
// Code that runs to get information about the resource. | ||
export const getData = async (arn: string): Promise<Data> => { | ||
const { resource, accountId } = parse(arn); | ||
|
||
const getQueueUrlResponse = await client.send( | ||
new GetQueueUrlCommand({ | ||
QueueName: resource, | ||
}), | ||
); | ||
|
||
const getQueueAttributesResponse = await client.send( | ||
new GetQueueAttributesCommand({ | ||
QueueUrl: getQueueUrlResponse.QueueUrl, | ||
AttributeNames: ["All"], | ||
}), | ||
); | ||
|
||
const attributes = getQueueAttributesResponse?.Attributes || {}; | ||
|
||
const createdTimeStamp = attributes?.CreatedTimestamp | ||
? parseInt(attributes?.CreatedTimestamp) | ||
: undefined; | ||
const parseAttribute = (attribute: any) => | ||
attribute ? parseInt(attribute) || undefined : undefined; | ||
|
||
return { | ||
name: resource, | ||
description: "SQS Queue", | ||
AWS: { | ||
Arn: arn, | ||
Name: resource, | ||
CreatedTimestamp: createdTimeStamp | ||
? new Date(createdTimeStamp * 1000).toISOString() | ||
: undefined, | ||
VisibilityTimeout: parseAttribute(attributes.VisibilityTimeout), | ||
MaximumMessageSize: parseAttribute(attributes.MaximumMessageSize), | ||
MessageRetentionPeriod: parseAttribute(attributes.MessageRetentionPeriod), | ||
DelaySeconds: attributes.DelaySeconds, | ||
ReceiveMessageWaitTimeSeconds: attributes.ReceiveMessageWaitTimeSeconds, | ||
SqsManagedSseEnabled: attributes.SqsManagedSseEnabled, | ||
QueueUrl: getQueueUrlResponse.QueueUrl, | ||
Account: accountId, | ||
Service: "sqs", | ||
}, | ||
}; | ||
}; | ||
|
||
// Return the default markdown for new resources | ||
export const getMarkdown = (data: Data): Promise<string> => { | ||
return Promise.resolve(` | ||
## About this SQS queue | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in ligula et orci pellentesque volutpat. In imperdiet augue sit amet imperdiet ultricies. Etiam eget dui elementum, tempor ligula quis, consectetur eros. Suspendisse sodales mattis ex, nec tempor lorem. Maecenas eget risus suscipit, gravida lectus eu, dictum sapien. Nunc efficitur sem eget dui tempus aliquam. | ||
### Send a message to the SQS queue | ||
<CLICommand>aws sqs send-message --queue-url /QueueUrl/ --message-body "Hello, this is a test message"</CLICommand> | ||
`); | ||
}; | ||
export const getFileName = (data: Data): Promise<string> => { | ||
const name = data.AWS.Name || `new-${data.AWS.Service}-file`; | ||
return Promise.resolve(name); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ecea98b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
cloudcatalog-demo – ./packages/cloudcatalog
cloudcatalog-demo.vercel.app
cloudcatalog-demo-davidboyne123.vercel.app
cloudcatalog-demo-git-main-davidboyne123.vercel.app
app.cloudcatalog.dev