eventsender
This is a simple event sender that publishes JSON-serialisable messages to an AMQP server exchange. It can also be optionally installed as a Django application.
Installation and configuration
The following settings should be supplied either as environment variables or via Django settings module:
EVENT_QUEUE_URL = os.environ.get('EVENT_QUEUE_URL')
EVENT_QUEUE_EXCHANGE = os.environ.get('EVENT_QUEUE_EXCHANGE')
EVENT_QUEUE_ROUTING_KEY = os.environ.get('EVENT_QUEUE_ROUTING_KEY', '')
EVENT_QUEUE_ROUTING_KEY is optional and can be omitted (it will be assumed blank by default).
Usage
Example:
from eventsender import send_event
send_event({'type': 'user.subscribed', 'username': 'john_doe'})
Or
EVENT_QUEUE_EXCHANGE=some_exchange EVENT_QUEUE_URL=amqp://guest:guest@localhost:5672/host python -c \
"import eventsender; eventsender.send_event({'type': 'event_type', 'somedata': {'key': 'value'}})"
To publish a batch, use send_events. It sends the same messages as calling send_event for each of them, but over a single connection instead of one per event:
from eventsender import send_events
send_events([
{'type': 'user.subscribed', 'username': 'john_doe'},
{'type': 'user.subscribed', 'username': 'jane_doe'},
])
Tracing
send_event and send_events create an OpenTelemetry producer span per event and inject the current trace context into the AMQP message headers, so consumers can continue the trace. This only depends on opentelemetry-api, for applications without a configured OpenTelemetry backend all tracing calls are no-ops and the behaviour is unchanged. To get the spans into your tracing backend, configure an OpenTelemetry SDK in your application (for example by enabling the Sentry SDK’s OpenTelemetry support).
Running tests
Install uv and run uv run pytest tests.
About
This software is brought to you by Byte, a webhosting provider based in Amsterdam, The Netherlands. We specialize in fast and secure Magento hosting and scalable cluster hosting.
Check out our Github page for more open source software or our site to learn about our products and technologies. Looks interesting? Reach out about joining the team. Or just drop by for a cup of excellent coffee if you’re in town!
Metadata
Release files for eventsender 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| eventsender-1.4.0.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| eventsender-1.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / eventsender-1.4.0.tar.gz
| Download URL | eventsender-1.4.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
abbb5656a38743e128f6bd82f27183bc0db247ce305b83e2af16af2a20b7c242
|
|
BLAKE2b-256 checksum How to use checksums |
3596af7ebc68880fed9239323e94edc722bf1386841620957c0b1208665cee28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / eventsender-1.4.0-py3-none-any.whl
| Download URL | eventsender-1.4.0-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8fe66d582916de48ccedbc60aa6083c4234f373a8d315a0cf7ecce37f45940d
|
|
BLAKE2b-256 checksum How to use checksums |
222d9653ce44c915e99347fb9ef0c4232bdad92ee3109f293173f26dee4696f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|