1.0.0 • Published 9 years ago
palmettoflow-queuesvc v1.0.0
Palmetto Flow Queue Service
This PalmettoFlow service is a simple queue, you post documents in and you get documents out by queue
name.
Usage
Environment Variables
# you can set it to use a pouchdb server instead by just giving it a name
export COUCHSVR = 'http://localhost:5984'
# database name prefix to support multiple queue services
export PREFIX = 'app_'
# JWT_SECRET
export JWT_SECRET = 'secret here'
Register in Service Container
var ee = palmetto()
var svc = require('@lincs/queue-service')
svc(ee)
Usage in Client - Post Task to Queue
var newEvent = require('palmettoflow-event').newEvent
var ee = palmetto()
var ne = newEvent('queue', 'post', {
queue: 'queue_name',
... payload ....
}, {
token: jwtToken
})
ee.on(ne.from, function (event) {
// handle response
})
ee.emit('send', ne)
Usage in Client - Get Tasks from Queue
var newEvent = require('palmettoflow-event').newEvent
var ee = palmetto()
var ne = newEvent('queue', 'get', {
queue: 'queue_name',
}, {
token: jwtToken
})
ee.on(ne.from, function (event) {
// handle response
})
ee.emit('send', ne)
## Why Closures
The module is designed to be as static as Javascript allows,
following a functional or lambda programming paradigm. If you want to learn more
about this pattern of development and why this pattern was chosen above other,
more traditional, javascript approaches please read the following excellent article
http://howtonode.org/why-use-closure
If you would like to help maintain this project and/or if you have any questions or comments
about the library's design or implementation I'd love to hear from you.
1.0.0
9 years ago