Name | bovine-pubsub JSON |
Version |
0.5.18
JSON |
| download |
home_page | https://codeberg.org/bovine/bovine |
Summary | A Quart thing to handle pubsub tasks in particular the event source |
upload_time | 2025-02-07 18:14:19 |
maintainer | None |
docs_url | None |
author | Helge |
requires_python | <4.0,>=3.11 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<!--
SPDX-FileCopyrightText: 2023 Helge
SPDX-License-Identifier: MIT
-->
# bovine_pubsub
__Note__: Development of bovine_pubsub will probably be discontinued
bovine_pubsub is a simple wrapper to enable [server sent events](https://html.spec.whatwg.org/multipage/server-sent-events.html#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
```python
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
```python
await app.config["bovine_pub_sub"].send("channel:test", b"test")
```
one sends the bytes `b"test"` to the channel `channel:test`. By calling
```python
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
```bash
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
```bash
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.
```bash
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
```
Raw data
{
"_id": null,
"home_page": "https://codeberg.org/bovine/bovine",
"name": "bovine-pubsub",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": null,
"author": "Helge",
"author_email": "helge.krueger@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f6/51/f887a98aaeefa235cf346222d638f8a01a64a21a7ee0ade2cbdf2fda0e9f/bovine_pubsub-0.5.18.tar.gz",
"platform": null,
"description": "<!--\nSPDX-FileCopyrightText: 2023 Helge\n\nSPDX-License-Identifier: MIT\n-->\n\n# bovine_pubsub\n\n__Note__: Development of bovine_pubsub will probably be discontinued\n\nbovine_pubsub is a simple wrapper to enable [server sent events](https://html.spec.whatwg.org/multipage/server-sent-events.html#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.\n\nStarting with `bovine-pubsub` support for server side clients is available using AMQP. See `examples/bovine_listen.py` for details.\n\n## Usage\n\nThe simplest usage example is given by\n\n```python\nfrom quart import Quart\nfrom bovine_pubsub import BovinePubSub\n\napp = Quart(__name__)\nBovinePubSub(app)\n```\n\nit adds the config variable `app.config[\"bovine_pub_sub\"]` to the Quart application. By calling\n\n```python\nawait app.config[\"bovine_pub_sub\"].send(\"channel:test\", b\"test\")\n```\n\none sends the bytes `b\"test\"` to the channel `channel:test`. By calling\n\n```python\npub_sub.event_stream(\"channel:test\")\n```\n\none receives an async iterator that can be used as server sent events.\n\n## Example usage\n\nA usage example is provided by `examples/basic_app.py`. By running\n\n```bash\npython examples/basic.app\n```\n\none 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\n\n```bash\nBOVINE_REDIS=redis://localhost:6379 python examples/basic_app.py \n```\n\nwith an appropriate value for the environment variable `BOVINE_REDIS`.\n\n## Running tests\n\nTesting redis can be done inside of the docker compose setup, e.g.\n\n```bash\ndocker compose up -d\ndocker compose run main /bin/sh\ncd bovine_pubsub\npoetry install\npoetry run pytest\nBOVINE_REDIS=redis://redis:6379 poetry run pytest\nBOVINE_AMQP=amqp://rabbitmq poetry run pytest\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Quart thing to handle pubsub tasks in particular the event source",
"version": "0.5.18",
"project_urls": {
"Homepage": "https://codeberg.org/bovine/bovine",
"Repository": "https://codeberg.org/bovine/bovine"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cb7b1937e8e5cef9f21da2338a6bdff45228cf0ccda3fd1ce59556e79e65c374",
"md5": "30cb84cd09af3caf7bebfd201b82076e",
"sha256": "79073384dd2debf711be9bbf5cd2fa92fb7a85db9c789b7802cdf2f9af379fb6"
},
"downloads": -1,
"filename": "bovine_pubsub-0.5.18-py3-none-any.whl",
"has_sig": false,
"md5_digest": "30cb84cd09af3caf7bebfd201b82076e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 6820,
"upload_time": "2025-02-07T18:14:16",
"upload_time_iso_8601": "2025-02-07T18:14:16.354667Z",
"url": "https://files.pythonhosted.org/packages/cb/7b/1937e8e5cef9f21da2338a6bdff45228cf0ccda3fd1ce59556e79e65c374/bovine_pubsub-0.5.18-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f651f887a98aaeefa235cf346222d638f8a01a64a21a7ee0ade2cbdf2fda0e9f",
"md5": "6dcd0a44d06456111b0c87025937e77f",
"sha256": "f4ed9c9c7069671de07683728c28a099d6c7b92e9546f12dd14a0941686a751e"
},
"downloads": -1,
"filename": "bovine_pubsub-0.5.18.tar.gz",
"has_sig": false,
"md5_digest": "6dcd0a44d06456111b0c87025937e77f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 4253,
"upload_time": "2025-02-07T18:14:19",
"upload_time_iso_8601": "2025-02-07T18:14:19.809162Z",
"url": "https://files.pythonhosted.org/packages/f6/51/f887a98aaeefa235cf346222d638f8a01a64a21a7ee0ade2cbdf2fda0e9f/bovine_pubsub-0.5.18.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-07 18:14:19",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": true,
"codeberg_user": "bovine",
"codeberg_project": "bovine",
"lcname": "bovine-pubsub"
}