Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions configurer/queue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
| is used by your application. A default configuration has been added
| for each back-end shipped with Athenna. You are free to add more.
|
| Drivers: "memory", "database", "awsSqs", "fake"
| Drivers: "memory", "database", "aws_sqs", "fake"
|
*/

Expand All @@ -35,7 +35,7 @@ export default {
attempts: 3
},

awsSqs: {
aws_sqs: {
driver: 'aws_sqs',
queue: 'queue_name',
deadletter: 'deadletter_queue_name',
Expand Down
6 changes: 3 additions & 3 deletions configurer/worker
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default {
*/

logger: {
enabled: Env('LOG_WORKER', true),
prettifyException: Env('LOG_PRETTY', true)
},
enabled: Env('LOG_WORKER', false),
prettifyException: Env('LOG_PRETTY', false)
}
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/queue",
"version": "5.13.0",
"version": "5.14.0",
"description": "The Athenna queue handler.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
25 changes: 18 additions & 7 deletions src/drivers/AwsSqsDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,24 @@ export class AwsSqsDriver extends Driver<SQSClient> {
return
}

this.client = new SQSClient({
region: this.region,
credentials: {
accessKeyId: this.awsAccessKeyId,
secretAccessKey: this.awsSecretAccessKey
}
})
let sqsClientOptions: any = {
region: this.region,
credentials: {
accessKeyId: this.awsAccessKeyId,
secretAccessKey: this.awsSecretAccessKey
}
}

/**
* If the AWS_SESSION_TOKEN is set, it means that the session is running inside
* AWS. In this case, we can't set any options to SQSClient, otherwise the client
* will fail to authenticate.
*/
if (Env('AWS_SESSION_TOKEN')) {
sqsClientOptions = {}
}

this.client = new SQSClient(sqsClientOptions)
this.isConnected = true
this.isSavedOnFactory = options.saveOnFactory

Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/config/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
| is used by your application. A default configuration has been added
| for each back-end shipped with Athenna. You are free to add more.
|
| Drivers: "memory", "database", "awsSqs", "fake"
| Drivers: "memory", "database", "aws_sqs", "fake"
|
*/

Expand All @@ -55,7 +55,7 @@ export default {
}
},

awsSqs: {
aws_sqs: {
driver: 'aws_sqs',
type: 'standard',
queue: 'https://sqs.sa-east-1.amazonaws.com/528757804004/athenna_queue',
Expand Down
30 changes: 15 additions & 15 deletions tests/unit/drivers/AwsSqsDriverTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ export class AwsSqsDriverTest extends BaseTest {

@Test()
public async shouldBeAbleToConnectToDriver({ assert }: Context) {
Queue.connection('awsSqs')
Queue.connection('aws_sqs')

assert.isTrue(Queue.isConnected())
}

@Test()
public async shouldBeAbleToCloseTheConnectionWithDriver({ assert }: Context) {
const queue = Queue.connection('awsSqs')
const queue = Queue.connection('aws_sqs')

await queue.close()

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

@Test()
public async shouldBeAbleToCloneTheQueueInstance({ assert }: Context) {
const driver = Queue.connection('awsSqs').driver
const driver = Queue.connection('aws_sqs').driver
const otherDriver = driver.clone()

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

@Test()
public async shouldBeAbleToGetDriverClient({ assert }: Context) {
const client = Queue.connection('awsSqs').driver.getClient()
const client = Queue.connection('aws_sqs').driver.getClient()

assert.isDefined(client)
}

@Test()
public async shouldBeAbleToSetDifferentClientForDriver({ assert }: Context) {
const driver = Queue.connection('awsSqs').driver
const driver = Queue.connection('aws_sqs').driver

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

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

@Test()
public async shouldBeAbleToSeeHowManyJobsAreInsideTheQueue({ assert }: Context) {
const length = await Queue.connection('awsSqs').length()
const length = await Queue.connection('aws_sqs').length()

assert.isTrue(Is.Number(length))
}

@Test()
public async shouldBeAbleToAddJobsToTheQueue({ assert }: Context) {
const queue = Queue.connection('awsSqs')
const queue = Queue.connection('aws_sqs')

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

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

@Test()
public async shouldBeAbleToVerifyIfTheQueueIsEmpty({ assert }: Context) {
const queue = Queue.connection('awsSqs')
const queue = Queue.connection('aws_sqs')

const isEmpty = await queue.isEmpty()

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

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

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

@Test()
public async shouldBeAbleToPopTheNextJobRemovingItFromTheQueue({ assert }: Context) {
const queue = Queue.connection('awsSqs')
const queue = Queue.connection('aws_sqs')

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

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

const queue = Queue.connection('awsSqs')
const queue = Queue.connection('aws_sqs')

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

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

@Test()
public async shouldBeAbleToSendTheJobToDeadletterQueueIfProcessorFails({ assert }: Context) {
const queue = Queue.connection('awsSqs')
const queue = Queue.connection('aws_sqs')

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

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

const isEmpty = await queue.queue(Config.get('queue.connections.awsSqs.deadletter')).isEmpty()
const isEmpty = await queue.queue(Config.get('queue.connections.aws_sqs.deadletter')).isEmpty()

assert.isFalse(isEmpty)
}
Expand Down Expand Up @@ -193,15 +193,15 @@ export class AwsSqsDriverTest extends BaseTest {
throw new Error('testing')
})

const isEmpty = await queue.queue(Config.get('queue.connections.awsSqs.deadletter')).isEmpty()
const isEmpty = await queue.queue(Config.get('queue.connections.aws_sqs.deadletter')).isEmpty()

assert.isFalse(isEmpty)
}

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

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

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/factories/ConnectionFactoryTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class ConnectionFactoryTest {

@Test()
public async shouldBeAbleToFabricateNewConnectionsAndReturnAwsSqsDriverInstance({ assert }: Context) {
const driver = ConnectionFactory.fabricate('awsSqs')
const driver = ConnectionFactory.fabricate('aws_sqs')

assert.instanceOf(driver, AwsSqsDriver)
}
Expand Down
Loading