1.1.6 • Published 3 years ago

redis-pubsub-rpc v1.1.6

Weekly downloads
3
License
ISC
Repository
github
Last release
3 years ago

redis-pubsub-rpc

Build Status Coverage Status

This library provide lightweight RPC layer over Redis Pub/Sub.

Installation

npm install --save redis-pubsub-rpc

Getting started

Register handler in server application

import {Server} from 'redis-pubsub-rpc'

const server = new Server('redis://127.0.0.1:6379')

server.addHandler('string.uppercase', (message) => message.toUpperCase())

And call the method from a client

import {Client} from 'redis-pubsub-rpc'

const client = new Client('redis://127.0.0.1:6379')

client.call('string.uppercase', ['text']).then(console.log) // Prints 'TEXT'

You may also specify serverId and communicate with many servers in one application

// create server with id
const server = new Server('redis://127.0.0.1:6379', {
  serverId: 'worker-0',
  applicationName: 'example'
})

const client = new Client('redis://127.0.0.1:6379', {
  applicationName: 'example'
})

// and specify serverId in call invocation

client.call('string.uppercase', ['text'], 'worker-0')

If you need to remove handler

server.removeHandler('string.uppercase')

To shutdown client and server call method quit()

client.quit()
server.quit()
1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago