Skip to content

Commit bb1418d

Browse files
committed
fix(sqs): enable users to supply their own SQS component to the construct
1 parent 3b8c787 commit bb1418d

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

API.md

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ A library containing a set of re-usable AWS CDK constructs.
88
npm install @serverless-dna/constructs
99
```
1010

11-
## The Constructs
11+
# The Constructs
1212

13-
### SocketApi
13+
## SocketApi
1414

1515
This construct creates an AWS WebSocket API with routes that are handled by AWS Lambda functions. A WebSocket can only exist when there are one or more valid integrations defined. If you do not define any integrations the WebSocket API will not be deployed.
1616

17-
#### Getting Started
17+
### Getting Started
1818

1919
The SocketAPI accepts an array of route definitions of type **ISocketFunction**.
2020

@@ -55,11 +55,11 @@ export class ApplicationStack extends Stack {
5555
}
5656
```
5757

58-
#### SocketTasks
58+
## SocketTasks
5959

6060
This construct inherits from the SocketAPI and creates a complete Asycnrhonouse Task Execution framework using WebSockets and AWS Lambda for running long-running tasks.
6161

62-
#### Getting Started
62+
### Getting Started
6363

6464
```typescript
6565
import { SocketTasks } from '@serverless-dna/constructs';

src/socket-tasks/socket-tasks.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,25 @@ export interface ITaskFunctionConfig {
1616
export interface ISocketTasksConfig {
1717
readonly socketApiConfig?: ISocketApiConfig;
1818
readonly eventBus?: IEventBus;
19+
readonly notifySQS?: IQueue;
1920
readonly taskFunctions: ITaskFunctionConfig[];
2021
}
2122

2223
export class SocketTasks extends SocketApi {
2324
readonly eventBus: IEventBus;
25+
readonly notifySQS: IQueue;
2426

2527
constructor(scope: Construct, id: string, config: ISocketTasksConfig) {
2628
super(scope, id, config?.socketApiConfig);
2729

2830
this.eventBus = this.createEventBus(config?.eventBus);
31+
this.notifySQS = this.createNotifySQS(config?.notifySQS);
2932
this.createSubmitHandler(this.eventBus);
3033
this.configureTasks(config);
3134
}
3235

3336
protected configureTasks(config: ISocketTasksConfig): void {
34-
const notifyQueue = this.createNotifySQS();
35-
37+
const notifyQueue = this.notifySQS;
3638
this.createNotifyHandler(notifyQueue);
3739

3840
config?.taskFunctions.forEach(
@@ -53,8 +55,8 @@ export class SocketTasks extends SocketApi {
5355
);
5456
}
5557

56-
protected createNotifySQS(): IQueue {
57-
return new Queue(this, 'notify-queue', {});
58+
protected createNotifySQS(theQueue?: IQueue): IQueue {
59+
return theQueue ?? new Queue(this, 'notify-queue', {});
5860
}
5961

6062
protected createEventBus(theBus?: IEventBus): IEventBus {

0 commit comments

Comments
 (0)