Skip to main content

Send and receive messages via a Redis server

Project description

RedisBridge

RedisBridge is a Python package that handles sending and receiving messages across clients via a Redis server.

Installation

pip install RedisBridge

Requirements

  • RedisBridge is intended to connect to a Redis server. To install and run Redis, see the instructions here.
  • RedisBridge supports Python 3.6 or later.

Getting Started

  1. Spin up a Redis server
$ redis-server --port 6379 &
  1. Create a bridge on each client
>>> from RedisBridge import RedisBridge
>>> bridge = RedisBridge(host='localhost', port=6379)
  1. Register callbacks to receive messages
>>> def callback(msg):
...     print('Received message:', msg)

>>> bridge.register_callback(callback, 'my_channel')
  1. Start each bridge to begin sending/receiving messages
>>> bridge.start()
  1. Send messages to other clients via bridge
>>> bridge.send('Hello World!', 'my_channel')

Each bridge calls all callbacks registered with it on the given channel

Received message: <Message: id='t2yedxi3', channel='my_channel', data='Hello World!'>
  1. Stop a bridge to close its connection to the server
>>> bridge.stop()

Docs

For much more detail about RedisBridge classes, messages, and usage patterns, check out the documentation. Seriously, go take a look.

Demos

For some toy examples and demos, check out the demos folder.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

RedisBridge-2.0.4.tar.gz (10.0 kB view hashes)

Uploaded Source

Built Distribution

RedisBridge-2.0.4-py3-none-any.whl (12.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page