kyew

2.1.2 • Public • Published

kyew

Message queue system written in Node.js and backed by Redis

Install

$ npm i kyew

Usage

const Kyew = require('kyew');
 
const kyew = new Kyew({
  url: 'redis://localhost:6379/1'
});

API

new Kyew([options])

options

Type: Object

url

Type: String

A redis url e.g. redis://localhost:6379/1

If you have redis-server running on the same machine as node, then the defaults for port and host are probably fine and you don't need to supply any redis url.

.pushMessage(options)

Add a message to the queue.

options

Type: Object

qname

Type: String

message

Type: Object

kyew
  .pushMessage({
    qname: 'queue',
    message: {
      id: '545f4c71-41f1-4582-bfb6-94a27d0ecf18',
      …
    }
  })
  .then(res => {
    console.log(res);
  })
  .catch(err => {
    console.log(err);
  });

.popMessage(options)

Remove a message from the queue.

options

Type: Object

qname

Type: String

id

Type: String

Remove the latest message from the queue.

kyew
  .popMessage({
    qname: 'queue'
  })
  .then(message => {
    console.log(message);
  })
  .catch(err => {
    console.log(err);
  });

Remove a specific message (by id) from the queue.

kyew
  .popMessage({
    qname: 'queue',
    id: '545f4c71-41f1-4582-bfb6-94a27d0ecf18'
  })
  .then(message => {
    console.log(message);
  })
  .catch(err => {
    console.log(err);
  });

.getMessage(options)

Return a message (by id) from the queue. Can be used to check if a specific message exists in the queue.

options

Type: Object

qname

Type: String

id

Type: String

kyew
  .getMessage({
    qname: 'queue',
    id: '545f4c71-41f1-4582-bfb6-94a27d0ecf18'
  })
  .then(message => {
    console.log(message);
  })
  .catch(err => {
    console.log(err);
  });

Readme

Keywords

none

Package Sidebar

Install

npm i kyew

Weekly Downloads

1

Version

2.1.2

License

none

Last publish

Collaborators

  • andreruffert