Service Bus application pattern for Python with support for multiple messaging protocols.
Project description
SiraBus
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
- Service Bus: Overview of the service bus and its components.
- Hierarchical Topics: Explanation of hierarchical topics and how to use them.
- Event Handling: How to handle events using the service bus.
- Command Handling: How to handle commands using the service bus.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sirabus-0.7.0.tar.gz.
File metadata
- Download URL: sirabus-0.7.0.tar.gz
- Upload date:
- Size: 26.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2687727719bc3b41905172ad1bc1664b2ff6436c207802a6f0402827e652245
|
|
| MD5 |
e2efad67d76b20170a97c8c8dec192b2
|
|
| BLAKE2b-256 |
3f373fd3b16f56309ff92d251f697287e8b8db57a45d3826ee8e50f7ba2229ce
|
File details
Details for the file sirabus-0.7.0-py3-none-any.whl.
File metadata
- Download URL: sirabus-0.7.0-py3-none-any.whl
- Upload date:
- Size: 51.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bcc7458fa2d2638a61e086ea7142ddfdb61dcdb0eb62bfa5a6ec91b543abaab
|
|
| MD5 |
0ccfb981eee005bd0fa285810424cad8
|
|
| BLAKE2b-256 |
74bf290951905af40d284f40c55277f4f12a87ba9317b5409e08fec704333b2d
|