bovine-pubsub


Namebovine-pubsub JSON
Version 0.5.15 PyPI version JSON
download
home_pagehttps://codeberg.org/bovine/bovine
SummaryA Quart thing to handle pubsub tasks in particular the event source
upload_time2024-12-26 19:38:35
maintainerNone
docs_urlNone
authorHelge
requires_python<4.0,>=3.11
licenseMIT
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/06/4a/40ede2663806220f380215f86ac422c4df81c5e7bc5591aa57456165a5db/bovine_pubsub-0.5.15.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.15",
    "project_urls": {
        "Homepage": "https://codeberg.org/bovine/bovine",
        "Repository": "https://codeberg.org/bovine/bovine"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7e4666f8af06b088785a470fd0e4af9899d454506ebcdceed8b725b781430fc",
                "md5": "eeafc18b5948f4de33f5bd37e00edbdc",
                "sha256": "75042e83fe51a5ead888791b770cb5b46fe51ea9fd5f34ef3cbe00f71990df12"
            },
            "downloads": -1,
            "filename": "bovine_pubsub-0.5.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "eeafc18b5948f4de33f5bd37e00edbdc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 6819,
            "upload_time": "2024-12-26T19:38:33",
            "upload_time_iso_8601": "2024-12-26T19:38:33.471681Z",
            "url": "https://files.pythonhosted.org/packages/d7/e4/666f8af06b088785a470fd0e4af9899d454506ebcdceed8b725b781430fc/bovine_pubsub-0.5.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "064a40ede2663806220f380215f86ac422c4df81c5e7bc5591aa57456165a5db",
                "md5": "1ccb02e2d6876d8e1370166a3f8e83c5",
                "sha256": "b34c30d84c1a980d2646d04ae5b21374e5f3c94fd36e9014ae3afc4d2d339347"
            },
            "downloads": -1,
            "filename": "bovine_pubsub-0.5.15.tar.gz",
            "has_sig": false,
            "md5_digest": "1ccb02e2d6876d8e1370166a3f8e83c5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 4261,
            "upload_time": "2024-12-26T19:38:35",
            "upload_time_iso_8601": "2024-12-26T19:38:35.616871Z",
            "url": "https://files.pythonhosted.org/packages/06/4a/40ede2663806220f380215f86ac422c4df81c5e7bc5591aa57456165a5db/bovine_pubsub-0.5.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-26 19:38:35",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": true,
    "codeberg_user": "bovine",
    "codeberg_project": "bovine",
    "lcname": "bovine-pubsub"
}
        
Elapsed time: 0.60259s