RabbitBus
Feel RabbitMQ like HTTP
- Custom CorrelationManagers
- Regexp routes
Installation
RabbitBus requires Python 3.6 >, aioamqp.
Install the dependencies and library.
$ pip install rabbitbus
Example:
import asyncio
from rabbitbus.manager import DatabusApp, Configuration
from rabbitbus.acks.requests import AmqpRequest
from rabbitbus.acks.responses import AckResponse
async def my_view(request: AmqpRequest):
# Write your code here
return AckResponse(request)
def serve():
loop = asyncio.get_event_loop()
# Inherit from CorrelationManager for custom correlation storages
app = DatabusApp(conf=Configuration())
app.add_route(r'^CASH_REGISTER_EQUIPMENTS[a-zA-Z_]{4}$', my_view)
app.start(loop)
if __name__ == '__main__':
serve()
If message has reply_to property, you can make response like:
from rabbitbus.acks.requests import AmqpRequest
from rabbitbus.acks.responses import AckResponse
async def my_view(request: AmqpRequest):
# Write your code here
return AckResponse(request, data={"result": 1})
"reply_to" will be converted to the "routing_key" and message will be published to the app exchange. More about RPC you can read in RabbitMQ documentation
Sometimes you may need to pause consuming. Three method are to your needs:
app.pause_consuming()
app.continue_consuming()
app.is_paused() #bool to test if your app is paused
To send message from any view you can also use:
async def my_view(request: AmqpRequest):
# Write your code here
request.app.send_message(data={"test": True}, routing_key="TEST")
return AckResponse(request)
Metadata
Release files for rabbitbus 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rabbitbus-0.1.2.tar.gz | 7.7 kB | Without provenance | Details for rabbitbus-0.1.2.tar.gz |
Release files / rabbitbus-0.1.2.tar.gz
| Download URL | rabbitbus-0.1.2.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a5dcb2ea7240c61eeae7276b1620913353918d847d9f43b683eeb35de4cc0da
|
|
BLAKE2b-256 checksum How to use checksums |
b0fcb84fe32dd46df29b7b65d0bf3bc6ca4a72c0f1a0256a7bdd2a5c941ca240
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|
Security for rabbitbus 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.