Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segment-boneyard/multipub
Clustered redis pub/sub
https://github.com/segment-boneyard/multipub
Last synced: about 5 hours ago
JSON representation
Clustered redis pub/sub
- Host: GitHub
- URL: https://github.com/segment-boneyard/multipub
- Owner: segment-boneyard
- Created: 2014-03-06T20:43:51.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-04-24T01:15:24.000Z (over 10 years ago)
- Last Synced: 2024-11-08T04:20:22.352Z (8 days ago)
- Language: JavaScript
- Size: 198 KB
- Stars: 63
- Watchers: 42
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# multipub
Multi-redis pub/sub allowing you to publish and subscribe to and from N redis nodes.
## Installation
```
$ npm install multipub
```## Example
Launch some redis nodes:
```
$ redis-server --port 4000 &
$ redis-server --port 4001 &
$ redis-server --port 4002 &
```PUB/SUB:
```js
var multipub = require('multipub');var client = multipub();
client.connect('localhost:4000');
client.connect('localhost:4001');
client.connect('localhost:4002');client.subscribe('user:*');
client.on('message', function(channel, msg){
console.log('%s - %s', channel, msg);
});setInterval(function(){
client.publish('user:login', { name: 'tobi' });
}, 50);setInterval(function(){
client.publish('user:login', { name: 'loki' });
}, 500);
```## API
### multipub(options)
Options are passed to node_redis's `.createClient()`.
```js
var multipub = require('multipub');
var client = multipub({
options: 'here'
});
```### Client#connect(addr)
Add connection to `addr`, for example "0.0.0.0:4000".
### Client#subscribe(pattern)
Subscribe to a channel or pattern, such as "user:login" or "user:*".
### Client#unsubscribe(pattern)
Unsubscribe from a channel or pattern, must match _exactly_ what you
passed to `.subscribe()`.# License
MIT