Skip to content

Commit 860fb87

Browse files
authored
Merge pull request #29 from AthennaIO/develop
chore: update dependencies
2 parents 73aaa87 + 5791ddd commit 860fb87

File tree

8 files changed

+44
-33
lines changed

8 files changed

+44
-33
lines changed

configurer/queue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default {
2323
| is used by your application. A default configuration has been added
2424
| for each back-end shipped with Athenna. You are free to add more.
2525
|
26-
| Drivers: "memory", "database", "awsSqs", "fake"
26+
| Drivers: "memory", "database", "aws_sqs", "fake"
2727
|
2828
*/
2929

@@ -35,7 +35,7 @@ export default {
3535
attempts: 3
3636
},
3737

38-
awsSqs: {
38+
aws_sqs: {
3939
driver: 'aws_sqs',
4040
queue: 'queue_name',
4141
deadletter: 'deadletter_queue_name',

configurer/worker

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default {
2626
*/
2727

2828
logger: {
29-
enabled: Env('LOG_WORKER', true),
30-
prettifyException: Env('LOG_PRETTY', true)
31-
},
29+
enabled: Env('LOG_WORKER', false),
30+
prettifyException: Env('LOG_PRETTY', false)
31+
}
3232
}

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/queue",
3-
"version": "5.13.0",
3+
"version": "5.14.0",
44
"description": "The Athenna queue handler.",
55
"license": "MIT",
66
"author": "João Lenon <[email protected]>",

src/drivers/AwsSqsDriver.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,24 @@ export class AwsSqsDriver extends Driver<SQSClient> {
141141
return
142142
}
143143

144-
this.client = new SQSClient({
145-
region: this.region,
146-
credentials: {
147-
accessKeyId: this.awsAccessKeyId,
148-
secretAccessKey: this.awsSecretAccessKey
149-
}
150-
})
144+
let sqsClientOptions: any = {
145+
region: this.region,
146+
credentials: {
147+
accessKeyId: this.awsAccessKeyId,
148+
secretAccessKey: this.awsSecretAccessKey
149+
}
150+
}
151+
152+
/**
153+
* If the AWS_SESSION_TOKEN is set, it means that the session is running inside
154+
* AWS. In this case, we can't set any options to SQSClient, otherwise the client
155+
* will fail to authenticate.
156+
*/
157+
if (Env('AWS_SESSION_TOKEN')) {
158+
sqsClientOptions = {}
159+
}
160+
161+
this.client = new SQSClient(sqsClientOptions)
151162
this.isConnected = true
152163
this.isSavedOnFactory = options.saveOnFactory
153164

tests/fixtures/config/queue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default {
3232
| is used by your application. A default configuration has been added
3333
| for each back-end shipped with Athenna. You are free to add more.
3434
|
35-
| Drivers: "memory", "database", "awsSqs", "fake"
35+
| Drivers: "memory", "database", "aws_sqs", "fake"
3636
|
3737
*/
3838

@@ -55,7 +55,7 @@ export default {
5555
}
5656
},
5757

58-
awsSqs: {
58+
aws_sqs: {
5959
driver: 'aws_sqs',
6060
type: 'standard',
6161
queue: 'https://sqs.sa-east-1.amazonaws.com/528757804004/athenna_queue',

tests/unit/drivers/AwsSqsDriverTest.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ export class AwsSqsDriverTest extends BaseTest {
3838

3939
@Test()
4040
public async shouldBeAbleToConnectToDriver({ assert }: Context) {
41-
Queue.connection('awsSqs')
41+
Queue.connection('aws_sqs')
4242

4343
assert.isTrue(Queue.isConnected())
4444
}
4545

4646
@Test()
4747
public async shouldBeAbleToCloseTheConnectionWithDriver({ assert }: Context) {
48-
const queue = Queue.connection('awsSqs')
48+
const queue = Queue.connection('aws_sqs')
4949

5050
await queue.close()
5151

@@ -54,7 +54,7 @@ export class AwsSqsDriverTest extends BaseTest {
5454

5555
@Test()
5656
public async shouldBeAbleToCloneTheQueueInstance({ assert }: Context) {
57-
const driver = Queue.connection('awsSqs').driver
57+
const driver = Queue.connection('aws_sqs').driver
5858
const otherDriver = driver.clone()
5959

6060
driver.isConnected = false
@@ -64,14 +64,14 @@ export class AwsSqsDriverTest extends BaseTest {
6464

6565
@Test()
6666
public async shouldBeAbleToGetDriverClient({ assert }: Context) {
67-
const client = Queue.connection('awsSqs').driver.getClient()
67+
const client = Queue.connection('aws_sqs').driver.getClient()
6868

6969
assert.isDefined(client)
7070
}
7171

7272
@Test()
7373
public async shouldBeAbleToSetDifferentClientForDriver({ assert }: Context) {
74-
const driver = Queue.connection('awsSqs').driver
74+
const driver = Queue.connection('aws_sqs').driver
7575

7676
driver.setClient({ hello: 'world' } as any)
7777

@@ -80,14 +80,14 @@ export class AwsSqsDriverTest extends BaseTest {
8080

8181
@Test()
8282
public async shouldBeAbleToSeeHowManyJobsAreInsideTheQueue({ assert }: Context) {
83-
const length = await Queue.connection('awsSqs').length()
83+
const length = await Queue.connection('aws_sqs').length()
8484

8585
assert.isTrue(Is.Number(length))
8686
}
8787

8888
@Test()
8989
public async shouldBeAbleToAddJobsToTheQueue({ assert }: Context) {
90-
const queue = Queue.connection('awsSqs')
90+
const queue = Queue.connection('aws_sqs')
9191

9292
await queue.add({ hello: 'world' })
9393

@@ -98,7 +98,7 @@ export class AwsSqsDriverTest extends BaseTest {
9898

9999
@Test()
100100
public async shouldBeAbleToVerifyIfTheQueueIsEmpty({ assert }: Context) {
101-
const queue = Queue.connection('awsSqs')
101+
const queue = Queue.connection('aws_sqs')
102102

103103
const isEmpty = await queue.isEmpty()
104104

@@ -108,7 +108,7 @@ export class AwsSqsDriverTest extends BaseTest {
108108
@Test()
109109
@Skip('Peek is not supported in SQS.')
110110
public async shouldBeAbleToPeekTheNextJobWithoutRemovingItFromTheQueue({ assert }: Context) {
111-
const queue = Queue.connection('awsSqs')
111+
const queue = Queue.connection('aws_sqs')
112112

113113
await queue.add({ name: 'lenon' })
114114

@@ -124,7 +124,7 @@ export class AwsSqsDriverTest extends BaseTest {
124124

125125
@Test()
126126
public async shouldBeAbleToPopTheNextJobRemovingItFromTheQueue({ assert }: Context) {
127-
const queue = Queue.connection('awsSqs')
127+
const queue = Queue.connection('aws_sqs')
128128

129129
await queue.add({ name: 'lenon' })
130130

@@ -139,7 +139,7 @@ export class AwsSqsDriverTest extends BaseTest {
139139
public async shouldBeAbleToProcessTheNextJobFromTheQueueWithAProcessor({ assert }: Context) {
140140
assert.plan(1)
141141

142-
const queue = Queue.connection('awsSqs')
142+
const queue = Queue.connection('aws_sqs')
143143

144144
await queue.add({ name: 'lenon' })
145145

@@ -154,15 +154,15 @@ export class AwsSqsDriverTest extends BaseTest {
154154

155155
@Test()
156156
public async shouldBeAbleToSendTheJobToDeadletterQueueIfProcessorFails({ assert }: Context) {
157-
const queue = Queue.connection('awsSqs')
157+
const queue = Queue.connection('aws_sqs')
158158

159159
await queue.add({ name: 'lenon' })
160160

161161
await queue.process(async () => {
162162
throw new Error('testing')
163163
})
164164

165-
const isEmpty = await queue.queue(Config.get('queue.connections.awsSqs.deadletter')).isEmpty()
165+
const isEmpty = await queue.queue(Config.get('queue.connections.aws_sqs.deadletter')).isEmpty()
166166

167167
assert.isFalse(isEmpty)
168168
}
@@ -193,15 +193,15 @@ export class AwsSqsDriverTest extends BaseTest {
193193
throw new Error('testing')
194194
})
195195

196-
const isEmpty = await queue.queue(Config.get('queue.connections.awsSqs.deadletter')).isEmpty()
196+
const isEmpty = await queue.queue(Config.get('queue.connections.aws_sqs.deadletter')).isEmpty()
197197

198198
assert.isFalse(isEmpty)
199199
}
200200

201201
@Test()
202202
@Skip('PurgeQueue can only be called every 60 seconds.')
203203
public async shouldBeAbleToTruncateAllJobs({ assert }: Context) {
204-
const queue = Queue.connection('awsSqs')
204+
const queue = Queue.connection('aws_sqs')
205205

206206
await queue.add({ name: 'lenon' })
207207

tests/unit/factories/ConnectionFactoryTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class ConnectionFactoryTest {
7373

7474
@Test()
7575
public async shouldBeAbleToFabricateNewConnectionsAndReturnAwsSqsDriverInstance({ assert }: Context) {
76-
const driver = ConnectionFactory.fabricate('awsSqs')
76+
const driver = ConnectionFactory.fabricate('aws_sqs')
7777

7878
assert.instanceOf(driver, AwsSqsDriver)
7979
}

0 commit comments

Comments
 (0)