Skip to main content

A Quart thing to handle pubsub tasks in particular the event source

Project description

bovine_pubsub

bovine_pubsub is a simple wrapper to enable server sent events in bovine. These are used to communicate real time with clients without forcing them to use polling. If multiple workers are used with bovine, one needs to use Redis as the implementation with queues only works for a single process.

Starting with bovine-pubsub support for server side clients is available using AMQP. See examples/bovine_listen.py for details.

Usage

The simplest usage example is given by

from quart import Quart
from bovine_pubsub import BovinePubSub

app = Quart(__name__)
BovinePubSub(app)

it adds the config variable app.config["bovine_pub_sub"] to the Quart application. By calling

await app.config["bovine_pub_sub"].send("channel:test", b"test")

one sends the bytes b"test" to the channel channel:test. By calling

pub_sub.event_stream("channel:test")

one receives an async iterator that can be used as server sent events.

Example usage

A usage example is provided by examples/basic_app.py. By running

python examples/basic.app

one can start a server that sends "test" 10 times a new socket is opened on localhost:5000. The above implementation will use the local queues. To use with Redis start

BOVINE_REDIS=redis://localhost:6379 python examples/basic_app.py 

with an appropriate value for the environment variable BOVINE_REDIS.

Running tests

Testing redis can be done inside of the docker compose setup, e.g.

docker compose up -d
docker compose run main /bin/sh
cd bovine_pubsub
poetry install
poetry run pytest
BOVINE_REDIS=redis://redis:6379 poetry run pytest
BOVINE_AMQP=amqp://rabbitmq poetry run pytest

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

bovine_pubsub-0.5.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bovine_pubsub-0.5.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file bovine_pubsub-0.5.1.tar.gz.

File metadata

  • Download URL: bovine_pubsub-0.5.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/6.1.0-0.deb11.6-amd64

File hashes

Hashes for bovine_pubsub-0.5.1.tar.gz
Algorithm Hash digest
SHA256 fb9781e9882f51c6c81479664d88334c9c35b76cf28d414c9e0a406eb747b94a
MD5 c96d4ed5c99a2d0e738ee6e8385496cf
BLAKE2b-256 5f933059e502096718aa66b20f2ee57481188db20cb84e18a86f065d0474c4fd

See more details on using hashes here.

File details

Details for the file bovine_pubsub-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: bovine_pubsub-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/6.1.0-0.deb11.6-amd64

File hashes

Hashes for bovine_pubsub-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a8752c5f37170d93849d3273356fcceee7c81e999d388459dd5bd760334946a7
MD5 fcf9c7a5be824a0f268e1ad74354ae81
BLAKE2b-256 8e2f53aff308614376c522d918d34c02e363bf891813b0a92aaaefe021b8bc92

See more details on using hashes here.

Supported by

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