broadcast-service


Namebroadcast-service JSON
Version 2.1.0 PyPI version JSON
download
home_pagehttps://github.com/Undertone0809/broadcast-service
SummaryA lightweight third-party broadcast/pubsub library
upload_time2023-06-15 13:10:57
maintainer
docs_urlNone
authorZeeland
requires_python>=3.6
licenseApache 2.0
keywords broadcast broadcast-service publisher subscriber pubsub
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
    broadcast-service
</h1>
<p align="center">
  <strong>A powerful python broadcast library. You can easily construct a Broadcast pattern/Publish subscriber pattern through this library.</strong>
</p>

<p align="center">
    <a target="_blank" href="">
        <img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?label=license" />
    </a>
   <a target="_blank" href=''>
        <img src="https://img.shields.io/github/stars/Undertone0809/broadcast-service.svg" alt="github stars"/>
   </a>
    <a target="_blank" href=''>
        <img src="https://static.pepy.tech/personalized-badge/broadcast-service?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Downloads/Total"/>
   </a>
    <a target="_blank" href=''>
        <img src="https://static.pepy.tech/personalized-badge/broadcast-service?period=month&units=international_system&left_color=grey&right_color=blue&left_text=Downloads/Week"/>
   </a>
</p>


## Features
- A publishing subscriber pattern can be built with a very simple syntax
- Support different application scenarios, such as asynchronous and synchronous
- Provide different syntax writing modes for lambda, callback functions, decorators, etc
- A callback function listens on multiple subscriptions
- Provide publisher dispatch callback manage

## Quick Start
- [document github-pages](https://undertone0809.github.io/broadcast-service/#/)
- [document gitee-pages](https://zeeland.gitee.io/broadcast-service/#/)
- [https://pypi.org/project/broadcast-service/](https://pypi.org/project/broadcast-service/)

## Setup

```sh
pip install broadcast-service
```

## Usage
There is an easy demo to show how to use broadcast-service.

```python
from broadcast_service import broadcast_service

# callback of decorator
@broadcast_service.on_listen('my_topic')
def handle_decorator_msg(params):
    print(f"handle_decorator_msg receive params: {params}")

if __name__ == '__main__':
    info = 'This is very important msg'

    # publish broadcast
    broadcast_service.publish('my_topic', info)
```

- You can use `publish, emit, broadcast` to send your topic msg and use `listen, on, subscribe` to listen your topic msg.

- You can also add more arguments or no argument when you publish thr broadcast.

```python
from broadcast_service import broadcast_service

# subscribe topic
@broadcast_service.on_listen(['my_topic'])
def handle_msg(info, info2):
    print(info)
    print(info2)

if __name__ == '__main__':
    info = 'This is very important msg'
    info2 = 'This is also a very important msg.'

    # publish broadcast
    broadcast_service.publish('my_topic', info, info2)
```
```python
from broadcast_service import broadcast_service

# subscribe topic
@broadcast_service.on_listen(['my_topic'])
def handle_msg():
    print('handle_msg callback')

if __name__ == '__main__':
    # publish broadcast
    broadcast_service.publish('Test')
```

You can use `config` to make publisher callback If you want.

```python
from broadcast_service import broadcast_service


@broadcast_service.on_listen("topic")
def handle_subscriber_callback():
    print("handle_subscriber_callback")


def handle_publisher_callback(*args):
    print("handle_publisher_callback")


if __name__ == '__main__':
    broadcast_service.config(
        num_of_executions=5,
        callback=handle_publisher_callback,
        enable_final_return=True,
        interval=0.1
    ).publish("topic")

```

Moreover, you can see more example in [document](https://undertone0809.github.io/broadcast-service/#/).

## TODO
- optimize documents and show more examples.
- ~~optimize the syntax expression of broadcast-service~~
- provide more test cases
- provide the ability to subscribe the topic and callback once
- support for fuzzy subscriptions
- ~~the publisher of the topic can provide a return value~~
- optimize usage in class ('self' params problem)
- build observer mode
- ~~provide publisher callback when all subscriber have completed callback~~


## Contribution
If you want to contribute to this project, you can submit pr or issue. I am glad to see more people involved and optimize it.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Undertone0809/broadcast-service",
    "name": "broadcast-service",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "broadcast,broadcast-service,publisher,subscriber,pubsub",
    "author": "Zeeland",
    "author_email": "zeeland@foxmail.com",
    "download_url": "https://files.pythonhosted.org/packages/16/17/c267994135cfd26dd460c93105ffe37592f59c33c872787d4acf1bc1760c/broadcast_service-2.1.0.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\n    broadcast-service\n</h1>\n<p align=\"center\">\n  <strong>A powerful python broadcast library. You can easily construct a Broadcast pattern/Publish subscriber pattern through this library.</strong>\n</p>\n\n<p align=\"center\">\n    <a target=\"_blank\" href=\"\">\n        <img src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg?label=license\" />\n    </a>\n   <a target=\"_blank\" href=''>\n        <img src=\"https://img.shields.io/github/stars/Undertone0809/broadcast-service.svg\" alt=\"github stars\"/>\n   </a>\n    <a target=\"_blank\" href=''>\n        <img src=\"https://static.pepy.tech/personalized-badge/broadcast-service?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Downloads/Total\"/>\n   </a>\n    <a target=\"_blank\" href=''>\n        <img src=\"https://static.pepy.tech/personalized-badge/broadcast-service?period=month&units=international_system&left_color=grey&right_color=blue&left_text=Downloads/Week\"/>\n   </a>\n</p>\n\n\n## Features\n- A publishing subscriber pattern can be built with a very simple syntax\n- Support different application scenarios, such as asynchronous and synchronous\n- Provide different syntax writing modes for lambda, callback functions, decorators, etc\n- A callback function listens on multiple subscriptions\n- Provide publisher dispatch callback manage\n\n## Quick Start\n- [document github-pages](https://undertone0809.github.io/broadcast-service/#/)\n- [document gitee-pages](https://zeeland.gitee.io/broadcast-service/#/)\n- [https://pypi.org/project/broadcast-service/](https://pypi.org/project/broadcast-service/)\n\n## Setup\n\n```sh\npip install broadcast-service\n```\n\n## Usage\nThere is an easy demo to show how to use broadcast-service.\n\n```python\nfrom broadcast_service import broadcast_service\n\n# callback of decorator\n@broadcast_service.on_listen('my_topic')\ndef handle_decorator_msg(params):\n    print(f\"handle_decorator_msg receive params: {params}\")\n\nif __name__ == '__main__':\n    info = 'This is very important msg'\n\n    # publish broadcast\n    broadcast_service.publish('my_topic', info)\n```\n\n- You can use `publish, emit, broadcast` to send your topic msg and use `listen, on, subscribe` to listen your topic msg.\n\n- You can also add more arguments or no argument when you publish thr broadcast.\n\n```python\nfrom broadcast_service import broadcast_service\n\n# subscribe topic\n@broadcast_service.on_listen(['my_topic'])\ndef handle_msg(info, info2):\n    print(info)\n    print(info2)\n\nif __name__ == '__main__':\n    info = 'This is very important msg'\n    info2 = 'This is also a very important msg.'\n\n    # publish broadcast\n    broadcast_service.publish('my_topic', info, info2)\n```\n```python\nfrom broadcast_service import broadcast_service\n\n# subscribe topic\n@broadcast_service.on_listen(['my_topic'])\ndef handle_msg():\n    print('handle_msg callback')\n\nif __name__ == '__main__':\n    # publish broadcast\n    broadcast_service.publish('Test')\n```\n\nYou can use `config` to make publisher callback If you want.\n\n```python\nfrom broadcast_service import broadcast_service\n\n\n@broadcast_service.on_listen(\"topic\")\ndef handle_subscriber_callback():\n    print(\"handle_subscriber_callback\")\n\n\ndef handle_publisher_callback(*args):\n    print(\"handle_publisher_callback\")\n\n\nif __name__ == '__main__':\n    broadcast_service.config(\n        num_of_executions=5,\n        callback=handle_publisher_callback,\n        enable_final_return=True,\n        interval=0.1\n    ).publish(\"topic\")\n\n```\n\nMoreover, you can see more example in [document](https://undertone0809.github.io/broadcast-service/#/).\n\n## TODO\n- optimize documents and show more examples.\n- ~~optimize the syntax expression of broadcast-service~~\n- provide more test cases\n- provide the ability to subscribe the topic and callback once\n- support for fuzzy subscriptions\n- ~~the publisher of the topic can provide a return value~~\n- optimize usage in class ('self' params problem)\n- build observer mode\n- ~~provide publisher callback when all subscriber have completed callback~~\n\n\n## Contribution\nIf you want to contribute to this project, you can submit pr or issue. I am glad to see more people involved and optimize it.\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "A lightweight third-party broadcast/pubsub library",
    "version": "2.1.0",
    "project_urls": {
        "Homepage": "https://github.com/Undertone0809/broadcast-service"
    },
    "split_keywords": [
        "broadcast",
        "broadcast-service",
        "publisher",
        "subscriber",
        "pubsub"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bb13d9683802227a2f396988146cb7aa7ccd12d226b20a5ba4c6f570e9b482c8",
                "md5": "0dfd13d41861f8f955cfd82cd0c74c82",
                "sha256": "72810f45b01afccd46f1a373d1c580bc79e862c924de23af20e9eda863d16c27"
            },
            "downloads": -1,
            "filename": "broadcast_service-2.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0dfd13d41861f8f955cfd82cd0c74c82",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 17142,
            "upload_time": "2023-06-15T13:10:55",
            "upload_time_iso_8601": "2023-06-15T13:10:55.629896Z",
            "url": "https://files.pythonhosted.org/packages/bb/13/d9683802227a2f396988146cb7aa7ccd12d226b20a5ba4c6f570e9b482c8/broadcast_service-2.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1617c267994135cfd26dd460c93105ffe37592f59c33c872787d4acf1bc1760c",
                "md5": "59e14c77b81cd215fc9f0242ff610386",
                "sha256": "7210f6fe17a9cb206d13cba7a11e443f95fb1904b7001f10a0273d61f1cd9eca"
            },
            "downloads": -1,
            "filename": "broadcast_service-2.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "59e14c77b81cd215fc9f0242ff610386",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12851,
            "upload_time": "2023-06-15T13:10:57",
            "upload_time_iso_8601": "2023-06-15T13:10:57.421287Z",
            "url": "https://files.pythonhosted.org/packages/16/17/c267994135cfd26dd460c93105ffe37592f59c33c872787d4acf1bc1760c/broadcast_service-2.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-15 13:10:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Undertone0809",
    "github_project": "broadcast-service",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "broadcast-service"
}
        
Elapsed time: 0.07997s