99
1010import { flags , BaseCommand } from '@adonisjs/core/ace'
1111import type { CommandOptions } from '@adonisjs/core/types/ace'
12- import type { QueueManagerConfig } from '@boringnode/queue /types'
12+ import type { QueueConfig } from '../src /types/main.js '
1313
1414export default class QueueWork extends BaseCommand {
1515 static commandName = 'queue:work'
@@ -28,7 +28,7 @@ export default class QueueWork extends BaseCommand {
2828
2929 async run ( ) {
3030 const { Worker } = await import ( '@boringnode/queue' )
31- const config = this . app . config . get < QueueManagerConfig > ( 'queue' )
31+ const config = this . app . config . get < QueueConfig > ( 'queue' )
3232
3333 /**
3434 * Commit the router to ensure all routes are registered.
@@ -38,12 +38,26 @@ export default class QueueWork extends BaseCommand {
3838 const router = await this . app . container . make ( 'router' )
3939 router . commit ( )
4040
41+ /**
42+ * Resolve adapter factories from config providers
43+ */
44+ const resolvedAdapters : Record < string , ( ) => any > = { }
45+
46+ for ( const [ name , adapterConfig ] of Object . entries ( config . adapters ) ) {
47+ if ( typeof adapterConfig === 'function' ) {
48+ resolvedAdapters [ name ] = adapterConfig as ( ) => any
49+ } else {
50+ resolvedAdapters [ name ] = await adapterConfig . resolver ( this . app )
51+ }
52+ }
53+
4154 const queues = this . queue ? this . queue . split ( ',' ) . map ( ( q ) => q . trim ( ) ) : [ 'default' ]
4255
4356 this . logger . info ( `Starting worker for queues: ${ queues . join ( ', ' ) } ` )
4457
4558 const worker = new Worker ( {
4659 ...config ,
60+ adapters : resolvedAdapters ,
4761 ...( this . concurrency && { concurrency : this . concurrency } ) ,
4862 } )
4963 await worker . start ( queues )
0 commit comments