RedisPS
Wrapper for easy communication between processes via Redis Pub/Sub.
Install
npm install redis-ps
yarn add redis-ps
Create instance
You can connect to socket:
'/tmp/redis.sock';
By Redis DSN:
'redis://:authpassword@127.0.0.1:6380/4';
Or by ordinary host and port:
port: 6379 // Redis port, default is 6379 host: '127.0.0.1' // Redis host is '127.0.0.1' family: 4 // 4 (IPv4) or 6 (IPv6) password: 'auth' db: 0
Listen messages
// listen method return Listener instanceredisPS;
Once
// if you want to wait until message will receive, you can use 'once' methodasync { // once return Promise with payload, so you can "await" they const payload = await redisPS;};
Emit messages
redisPS;
Roadmap
- Enable and use ESlint with Airbnb config
- Add tests with Ava
- Add possibility to set error timeout in 'once' listener
- Add option to allow only one callback in channel
- Optimize listening with pSubscribe
- Add Babel and use private fields in classes