Skip to main content

WebSocket SDK for Centrifugo (and any Centrifuge-based server) on top of Python asyncio library

Project description

centrifuge-python (work in progress)

This is a WebSocket SDK for Centrifugo server (and any Centrifuge-based server) on top of Python asyncio library.

Before starting to work with this library check out Centrifugo client SDK API specification as it contains common information about Centrifugal real-time SDK behavior.

The features implemented by this SDK can be found in SDK feature matrix.

Install

pip install centrifuge-python

Then in your code:

from centrifuge import Client

See example code and how to run it locally.

Run tests

To run tests first start Centrifugo server:

docker run -p 8000:8000 centrifugo/centrifugo:v5 centrifugo --client_insecure --log_level debug

And then:

python -m venv env
. env/bin/activate
pip install -r requirements.txt
python -m unittest discover -s tests

Run example

Start Centrifugo with config like this (defines namespace called "example", enables features used in the example):

{
  "token_hmac_secret_key": "secret",
  "namespaces": [
    {
      "name": "example",
      "presence": true,
      "history_size": 300,
      "history_ttl": "300s",
      "join_leave": true,
      "force_push_join_leave": true,
      "allow_publish_for_subscriber": true,
      "allow_presence_for_subscriber": true,
      "allow_history_for_subscriber": true
    }
  ]
}

And then:

python -m venv env
. env/bin/activate
pip install -r requirements.txt
python example.py

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

centrifuge_python-0.3.0b0.tar.gz (21.7 kB view hashes)

Uploaded Source

Built Distribution

centrifuge_python-0.3.0b0-py3-none-any.whl (20.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