Skip to main content

A lightweight third-party broadcast library

Project description

broadcast-service

broadcast-service is a lightweight python broadcast library. You can easily construct a broadcast pattern through this library.

Setup

pip install broadcast-service

Usage

There is a easy demo to show how to use broadcast-service.

from broadcast_service import broadcast_service

def handle_msg(params):
    print(params)

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

    # listen topic
    broadcast_service.listen('Test', handle_msg)

    # publish broadcast
    broadcast_service.broadcast('Test', info)

You can also add more params or no params when you publish thr broadcast.

from broadcast_service import broadcast_service

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.'

    # listen topic
    broadcast_service.listen('Test', handle_msg)

    # publish broadcast
    broadcast_service.broadcast('Test', info, info2)
from broadcast_service import broadcast_service

def handle_msg():
    print('handle_msg callback')

if __name__ == '__main__':
    # listen topic
    broadcast_service.listen('Test', handle_msg)

    # publish broadcast
    broadcast_service.broadcast('Test')

Actually, you can see more example in example.

TODO

  • optimize documents and show more examples.
  • optimize the syntax expression of broadcast-service
  • provide more test cases

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.

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

broadcast_service-1.1.6.tar.gz (6.7 kB view details)

Uploaded Source

File details

Details for the file broadcast_service-1.1.6.tar.gz.

File metadata

  • Download URL: broadcast_service-1.1.6.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.9

File hashes

Hashes for broadcast_service-1.1.6.tar.gz
Algorithm Hash digest
SHA256 e3ad8ff866d16ab5ad97dbc72489a7fc689570f50bf0ca8c50b0a39c56676e43
MD5 4acdeabf2bb2f2f63d398e0b86be58a8
BLAKE2b-256 df56fa01967e0f48d08330135ba796e9a2f973205d900065f1236942b0812b92

See more details on using hashes here.

Supported by

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