Skip to main content

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'}})"

Tracing

send_event creates an OpenTelemetry producer span for every publish and injects 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!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eventsender-1.3.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

eventsender-1.3.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file eventsender-1.3.0.tar.gz.

File metadata

  • Download URL: eventsender-1.3.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for eventsender-1.3.0.tar.gz
Algorithm Hash digest
SHA256 842d79eb9b003df74000c94718facf312ed94887197975953980a69cf077e62c
MD5 61ea82fb45ed73dedc4c53834709b2db
BLAKE2b-256 7c0271fcfaa2bf8e8385fc003a8945953563495583bd76e99a3faa4f6994f9f5

See more details on using hashes here.

File details

Details for the file eventsender-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: eventsender-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for eventsender-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8eb3370f55d841ad1af826f4be33ef992303c750d875025ceb14fc9562d0bdb8
MD5 196f1e7efbc62584aa1fd8c50c826a64
BLAKE2b-256 3f44a7fe7a88c25f67d70a1dc1519370ac7e8037c7825fffc528455bacdaae04

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 Sentry Error logging StatusPage Status page