Skip to main content

Message service implementing publisher/subscriber pattern

Project description

apubsub

Simple, single-purpose message service implementation.

Build Status Coverage PyPI version

Note that service is started in stand-alone process, so start it as early as possible to minimize resource pickling

Installation

Python versin 3.7+ required

Just install it with pip: pip install apubsub

Usage

The most simple usage is to subscribe to topic and receive single message:

from apubsub import Service

service = Service()
service.start()

pub = service.get_client()
sub = service.get_client()  # every client can perform both pub and sub roles

sub.subscribe('topic')

pub.publish('topic', 'some data')  # publish put data to subscribed Client queue

pub.publish('topic', 'some more data')
pub.publish('topic', 'and more')

data = sub.get_single(timeout=0.1)  # 'some data'

data = sub.get_all()  # ['some more data', 'and more']

Also, Client provides start_receiving async generator for receiving messages on-demand. It will wait for new messages until interrupted by stop_receiving call

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

apubsub-0.1.1.tar.gz (6.7 kB view hashes)

Uploaded Source

Built Distribution

apubsub-0.1.1-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

Supported by

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