Skip to content

Commit

Permalink
refactor(queue): migrate to @athenna/queue
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed May 17, 2024
1 parent 58e7746 commit f1e6106
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 358 deletions.
2 changes: 2 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ MAIL_HOST=localhost
MAIL_PORT=5025
MAIL_USERNAME=
MAIL_PASSWORD=

QUEUE_CONNECTION=vanilla
17 changes: 13 additions & 4 deletions package-lock.json

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

19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
},
"dependencies": {
"@athenna/artisan": "^4.42.0",
"@athenna/common": "^4.39.0",
"@athenna/common": "^4.40.0",
"@athenna/config": "^4.21.0",
"@athenna/core": "^4.38.0",
"@athenna/database": "^4.52.0",
"@athenna/http": "^4.34.0",
"@athenna/ioc": "^4.20.0",
"@athenna/logger": "^4.21.0",
"@athenna/mail": "^4.18.0",
"@athenna/queue": "^4.3.0",
"@athenna/validator": "^4.2.0",
"@athenna/view": "^4.22.0",
"@fastify/cors": "^8.5.0",
Expand Down Expand Up @@ -137,7 +138,6 @@
},
"athenna": {
"services": [
"#src/helpers/queue",
"#src/services/user.service",
"#src/services/auth.service"
],
Expand All @@ -150,7 +150,8 @@
"@athenna/mail/providers/MailProvider",
"@athenna/mail/providers/SmtpServerProvider",
"@athenna/validator/providers/ValidatorProvider",
"#src/providers/queueworker.provider"
"@athenna/queue/providers/QueueProvider",
"@athenna/queue/providers/WorkerProvider"
],
"controllers": [
"#src/controllers/user.controller",
Expand Down Expand Up @@ -227,7 +228,8 @@
"loadApp": true
},
"make:view": "@athenna/view/commands/MakeViewCommand",
"make:validator": "@athenna/validator/commands/MakeValidatorCommand"
"make:validator": "@athenna/validator/commands/MakeValidatorCommand",
"make:worker": "@athenna/queue/commands/MakeWorkerCommand"
},
"templates": {
"exception": "node_modules/@athenna/core/templates/exception.edge",
Expand All @@ -248,7 +250,8 @@
"migration": "node_modules/@athenna/database/templates/migration.edge",
"view": "node_modules/@athenna/view/templates/view.edge",
"validator-http": "node_modules/@athenna/validator/templates/validator-http.edge",
"validator-console": "node_modules/@athenna/validator/templates/validator-console.edge"
"validator-console": "node_modules/@athenna/validator/templates/validator-console.edge",
"worker": "node_modules/@athenna/queue/templates/worker.edge"
},
"directories": {
"bootstrap": "bin",
Expand All @@ -259,6 +262,8 @@
"providers": "src/providers",
"facades": "src/providers/facades",
"services": "src/services",
"jobs": "src/jobs",
"workers": "src/workers",
"validators": "src/validators",
"commands": "src/commands",
"controllers": "src/controllers",
Expand Down Expand Up @@ -288,8 +293,8 @@
"#src/validators/register.validator",
"#src/validators/update.validator"
],
"jobs": [
"#src/jobs/mail.job"
"workers": [
"#src/workers/mail.worker"
]
}
}
55 changes: 55 additions & 0 deletions src/config/queue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Env } from '@athenna/config'

export default {
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Athenna's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for every one. Here you may define a default connection.
|
*/

default: Env('QUEUE_CONNECTION', 'vanilla'),

/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| 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: "vanilla", "database", "fake"
|
*/

connections: {
vanilla: {
driver: 'vanilla',
queue: 'default',
workerInterval: 5000,
deadletter: 'deadletter'
},

database: {
driver: 'database',
table: 'jobs',
connection: 'postgres',
queue: 'default',
workerInterval: 1000,
deadletter: 'deadletter'
},

discard: {
driver: 'fake'
},

fake: {
driver: 'fake'
}
}
}
Loading

0 comments on commit f1e6106

Please sign in to comment.