Metadata-Version: 2.4
Name: eventsender
Version: 1.3.0
Summary: RabbitMQ event sender
Author-email: "Byte B.V." <tech@byte.nl>
License-Expression: MIT
Project-URL: Homepage, https://github.com/ByteInternet/eventsender
Keywords: amqp,rabbitmq,events,eventsender
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Utilities
Classifier: Topic :: Communications
Classifier: Topic :: Internet
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.9
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: pika<1.4,>=1.3.2
Requires-Dist: opentelemetry-api>=1.16
Dynamic: license-file

===========
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:

.. code-block:: python

    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:

.. code-block:: python

    from eventsender import send_event
    send_event({'type': 'user.subscribed', 'username': 'john_doe'})

Or

.. code-block:: bash

   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 <https://docs.astral.sh/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 <https://github.com/ByteInternet>`_ for more open source software or `our site <https://www.byte.nl>`_
to learn about our products and technologies. Looks interesting? Reach out about `joining the team <https://www.byte.nl/vacatures>`_.
Or just drop by for a cup of excellent coffee if you're in town!
