0.1.10 • Published 6 years ago
@amokrushin/redis-queue v0.1.10
redis-queue
WIP
Install
npm i @amokrushin/redis-queue
RedisQueue
- RedisQueue
- new RedisQueue(createClient, [options])
- instance
- .enqueue(payload) ⇒ Promise
- .dequeue() ⇒ Promise
- .cancel()
- static
new RedisQueue(createClient, options)
Creates a RedisQueue instance
Param | Type | Default | Description |
---|---|---|---|
createClient | function | Function returning Redis instance. | |
[options.pollTimeout] | number | 10000 | Force subscriber to poll a queue for a new item. Timer restarts every time after new item was enqueued. |
[options.notificationsChannel] | string | __redis-queue_notifications__ |
redisQueue.enqueue(payload) ⇒ Promise<>
Enqueue new message to a queue.
Param | Type | Description |
---|---|---|
payload | any | Any serializable payload. The payload is serialized using the .serialize() method. |
redisQueue.dequeue() ⇒ Promise<Object|null>
Dequeue message from a queue.
Returns: Promise<Object>
Property | Type | Description |
---|---|---|
id | string | Message identyfier |
payload | any | The payload deserialized using the .deserialize() method. |
ack | function | The function should be called if message processing was failed. |
nack | function | The function should be called if message processing was succesful. |