Skip to main content

Service Bus application pattern for Python with support for multiple messaging protocols.

Project description

SiraBus

Downloads

SiraBus is a simple opinionated library for publishing and subscribing to events in an asynchronous and type-safe manner (to the extent that type safety can be achieved in Python).

Users publish events to an IPublishEvents interface, and users can subscribe to events by passing instances of an IHandleEvents interface to a ServiceBus implementation.

There's a TopographyBuilder that allows you to build a service bus topology, which is a declaration of queues and exchanges (based on transport protocol) that the service bus will use. This is useful for setting up the service bus in a production environment.

Example Usage

from sirabus import HierarchicalTopicMap, IHandleEvents
from sirabus.servicebus.amqp_servicebus import AmqpServiceBus, AmqpServiceBusConfiguration
import asyncio


class MyEventHandler(IHandleEvents):
    async def handle(self, event, headers):
        print(f"Handling event: {event} with headers: {headers}")


topic_map = HierarchicalTopicMap()
config = (AmqpServiceBusConfiguration.default()
    .with_amqp_url("amqp://guest:guest@localhost/")
    .with_topic_map(topic_map=topic_map)
    .with_handlers(MyEventHandler()))
# It can be further configured with SSL options, prefetch count, etc.
service_bus = AmqpServiceBus(
    configuration=config
)
asyncio.run(service_bus.run())

The run method starts the service bus and begins consuming messages from RabbitMQ. The stop method should be called to gracefully shut down the service bus and close the connection to RabbitMQ.

The message handling feature sets up a simple example of how to use the library. It sets up a service bus, registers a handler for a specific event type, and then publishes an event. The handler receives the event and processes it.

Supported Message Transport Protocols

SiraBus supports the following message transport protocols:

Protocol Description
In-Memory For local development and testing.
AMQP For production use with RabbitMQ.
SQS For production use with AWS SQS.
Redis For production use with Redis.

Specific Topics

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

sirabus-0.7.1.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sirabus-0.7.1-py3-none-any.whl (51.3 kB view details)

Uploaded Python 3

File details

Details for the file sirabus-0.7.1.tar.gz.

File metadata

  • Download URL: sirabus-0.7.1.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sirabus-0.7.1.tar.gz
Algorithm Hash digest
SHA256 9bd8d17585d4bc1fd12c12e7aa1e76b71d5f4d77a7f4e984c31b0c61b5d67688
MD5 8c5d29a39b02e319bbd339dff81cd950
BLAKE2b-256 b2ab9556fb6835cf568df465713456295f7a6a00e961944f5e6f64818d468b64

See more details on using hashes here.

File details

Details for the file sirabus-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: sirabus-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 51.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sirabus-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c0927549b031600275099b02db0d69e8e0a60a2d22931d30b81b8e66ccd5973a
MD5 fc9d1a393aa8b774e4b6ef4087c17259
BLAKE2b-256 594a54aa53631f6a6fc171f14d66f51cd5002311550cb69ca3d33f339be92816

See more details on using hashes here.

Supported by

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