-
Notifications
You must be signed in to change notification settings - Fork 2
DbQueuesRouterPg
DbQueuesRouterPg
is a companion object to DbListenerPg routing incoming notifications to DbQueue instances.
const ch = new DbQueuesRouterPg (app, {
name: 'QR',
// test: (dbNotificationPg) => true,
// on: {
// 'job-end': job => doSomething (job.result)
// 'job-error': [
// job => reportOnce (job.error),
// job => reportTwice (job.error),
// ],
//},
})
Name | Description |
---|---|
app |
an Application instance. |
options |
a bag of options (see below) |
Name | Type | Default | Description |
---|---|---|---|
name |
String | the name, for logging | |
test |
DbNotificationPg => Boolean | ()=>true | the test selector see Router for details |
on |
Object | {} |
a bag of JobSource events handlers |
listener
and models
properties below are set while plugging this instance into some DbListenerPg by calling its .add () method.
Name | Description |
---|---|
app |
The Application this instance is bound to |
listener |
The DbListenerPg this instance is attached to |
models |
Set of DbModels of all DbPoolPg from the app.pools connected to the same database as the listener
|
Returns a DbQueue instance based on the notification
value or throws an Error if none is found.
In the base implementation, scans this.models
trying to finds the queue by getQueueName (notification)
as name.
Returns a supposed DbViewQueuePg name based on the notification
value.
In the base implementation, returns notification.payload
if it's a non empty string, otherwise, throws an Error.
This method is called for each DbQueue found in the model when the listener
property is set (normally, by calling .add ()).
In the base implementation, it copies handlers from this.on
to the target queue and then calls its .check ()
.
Invokes getQueue (notification)
, then calls its result's check () method.