Closed rglover closed 2 months ago
If you decide the force option, you could warn on server startup in the console if a queue definition is missing its database
option.
Had a lightbulb on this. You could just tell Joystick that a queue is external and on one of your other databases:
export default {
external: true,
database: {
provider: 'mongodb',
name: 'provision',
},
};
This would be the only thing in the queue definition. That way, you could attach an external queue to your app at process.queues.<queue_name>
but the data source would be in another database.
As long as a connection to the specified database exists, the mapping would take place and you could queue jobs across databases seamlessly.
Done.
I made shortsighted move in respect to queues. I currently limit an app to one
queues
database via the config, but there could be a scenario where you want to target different databases for different queues.Proposal I came up with is to add a
database
option to queue definitions like this:Internally, Joystick would check to see if this value is defined. If it is, it would set the target database to that provider/database name combo. If it's not set, it would default back to what it is now (just use the database with
queues: true
set).Only thing I don't like is that it could get confusing to have both options. May be worth forcing database specification instead of the
queues: true
thing. Problem there is if I only have one database, I wouldn't have aname
(that only applies when I have multiple db connections for the same provider). That could be mitigated by checking internally to see if there are multiples of the specified provider and if not, just get the first one (and if there are, check for the specificied name).