tfk-seneca-queue-mongodb
v1.0.8
Published
Seneca plugin for tfk queue with mongodb
Downloads
4
Readme
tfk-seneca-queue-mongodb
Usage
'use strict'
const seneca = require('seneca')()
const senecaQueue = require('tfk-seneca-queue-mongodb')
const queueOptions = {
TAG: 'seneca-queue-test',
MONGODB_URI: 'localhost/queuetest',
MONGODB_COLLECTION_NAME: 'senecaque'
}
seneca.add('role:info, info:queue', args => {
console.log(args)
})
seneca.use(senecaQueue, queueOptions)
seneca.listen(8000)
Messages handled
role: queue, cmd: add
Adds data to the queue
Seneca.act('role: queue, cmd: add', {key: 'test', value: 2}, (error, data) => {})
curl -d '{"role": "queue", "cmd":"add", "data":{"digg`":"datatest"}}' -v http://localhost:8000/act
role: queue, cmd: next
Get next data in queue
Seneca.act('role: queue, cmd: next', (error, data) => {})
curl -d '{"role": "queue", "cmd":"next"}' -v http://localhost:8000/act
role: queue, cmd: delete
Deletes data from queue
Seneca.act('role: queue, cmd: delete', {queueId: '1234'}, (error, data) => {})
curl -d '{"role": "queue", "cmd":"delete", "queueId":"1234"}' -v http://localhost:8000/act
Messages emitted
role: info, info: queue, msg: add
Message emitted on data added to queue.
Contains the document added in data
role: info, info: queue, msg: delete
Message emitted on data deleted from queue.
Contains the document deleted in data