thunk-disque
A thunk/promise-based disque client, support all disque features.
Features
- Auto meet nodes to cluster
- Auto connect available nodes on demand
- Auto select connection by jobId
http://disquebook.com/
中文教程https://github.com/antirez/disque
https://github.com/thunks/thunks
Installation
Node.js:
npm install thunk-disque
Demo
var disque = var client = disquevar clientP = disque // thunk APIclient { console return this} { console // null // 'DI81250b3ccbac68e6625e79c8e7c5b286b1dcd2ac05a0SQ' return this } { console // null // { // id: 'DI81250b3ccbac68e6625e79c8e7c5b286b1dcd2ac05a0SQ', // queue: 'queueA', // state: 'queued', // repl: 3, // ttl: 86400, // ctime: 1430579357544000000, // delay: 0, // retry: 8640, // 'nodes-delivered': // [ 'f0e652056250c887ed294a53fa9386ea05abb0be', // '2067c69f914c619ed9f348f5ce6e7532ec26e9a8', // '81250b3c4318f0b6463da3742c7cf7069a46b6f6' ], // 'nodes-confirmed': [], // 'next-requeue-within': 8639835, // 'next-awake-within': 8639335, // body: 'Hello' // } return this}; // promise APIclientP
API
var disque =
disque.createClient([port], [host], [options])
disque.createClient([addressArray], [options])
port
: {Number}, default:7711
;host
: {String}, default:'127.0.0.1'
;options
: {Object}, default:{}
;-
handleError
: {Boolean}, Optional, Handle client error event. Default:true
. -
authPass
: {String}, Optional, Default:''
. -
autoMeet
: {Boolean}, Optional, Default:false
. -
returnBuffers
: {Boolean}, Optional, Default:false
. -
usePromise
: {Boolean|Promise}, Optional, Default:false
.Use default Promise:
var disque =var client = disqueUse bluebird:
var disque =var Bluebird =var client = disque -
noDelay
: {Boolean}, Optional, Default:true
. Disables the Nagle algorithm. By default TCP connections use the Nagle algorithm, they buffer data before sending it off. Setting true for noDelay will immediately fire off data each time socket.write() is called. -
retryMaxDelay
: {Number}, Optional, Default:Infinity
. By default every time the client tries to connect and fails time before reconnection (delay) almost multiply by1.2
. This delay normally grows infinitely, but settingretryMaxDelay
limits delay to maximum value, provided in milliseconds. -
maxAttempts
: {Number}, Optional, Default:10
. By default client will try reconnecting until connected. SettingmaxAttempts
limits total amount of reconnects.
-
Create a disque client, return the client.
// connect to 127.0.0.1:7711var client1 = disquevar client2 = disque // connect to 127.0.0.1:7711, 127.0.0.1:7712// and auto meet them into clustervar client3 = redisvar client4 = redis // IPv4var client5 = redis // IPv6
disque.log([...])
var client = disqueclientredislog