1.0.2 • Published 4 years ago

function-bus-redis v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

function-bus-redis

An object storing functions by key. These can be then executed grouped by key.

Useful to coordinate execution across different processes.

Uses Redis pub/sub.

var FunctionBus = require('function-bus-redis');
var functionBus = new FunctionBus();

// queue functions by key
functionBus.queue('a', func1);
functionBus.queue('a', func2);
functionBus.queue('b', func3);

// number of functions queued by key
functionBus.len('a'); // 2
functionBus.len('b'); // 1
functionBus.len('c'); // 0

// execute the 2 functions with key "a"
// passing 3 arguments: 1, 2, 3
functionBus.execute('a', [1, 2, 3]);

It works also across different processes connected to the same redis.

Options:

  • serialize optional: function used to serialize the values when they are sent to redis
  • deserialize optional: function used to deserialize the values when they are received from redis
  • channelPrefix optional: the prefix used for redis pub/sub
  • redisConfig optional: node-redis configuration
  • pub/sub optional: redisClients (2 different!). If they are not passed they are created using redisConfig.
1.0.2

4 years ago

1.0.1

6 years ago

1.0.0

7 years ago

0.0.1

7 years ago