Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Tests Build License Python Format PyPi Mypy Ruff security: bandit

eventiq

Publish/Subscribe asyncio framework for Python

Installation

pip install eventiq

or

poetry add eventiq

Installing optional dependencies

pip install 'eventiq[broker]'

Available brokers

  • nats
  • rabbitmq
  • kafka
  • redis

Features

  • Modern, asyncio based python 3.8+ syntax
  • Minimal external dependencies
  • Automatic message parsing based on type annotations using pydantic
  • Code hot-reload
  • Highly scalable: each service can process hundreds of tasks concurrently, all messages are load balanced between all instances by default
  • Resilient - at least once delivery for all messages by default
  • Customizable & pluggable message encoders (json by default)
  • Multiple broker support
    • Nats
    • Kafka
    • Rabbitmq
    • Redis
  • Easily extensible via Middlewares
  • Cloud Events standard as base message structure (no more python specific *args and **kwargs in messages)
  • AsyncAPI documentation generation from code
  • Twelve factor app approach - stdout logging, configuration through environment variables
  • Available extensions for integrating with Prometheus (metrics) and OpenTelemetry (tracing, metrics)

Basic Usage

import asyncio
from eventiq import Service, Middleware, CloudEvent
from eventiq.backends.nats import JetStreamBroker

class SendMessageMiddleware(Middleware):
    async def after_broker_connect(self, *, service: Service):
        print(f"After service start, running with {service.broker}")
        await asyncio.sleep(10)
        for i in range(100):
            message = CloudEvent(topic="test.topic", data={"counter": i})
            await service.publish(message)
        print("Published messages(s)")

broker = JetStreamBroker(url="nats://localhost:4222")

service = Service(
    name="example-service",
    broker=broker,
    middlewares=[SendMessageMiddleware()]
)


@service.subscribe(topic="test.topic")
async def example_run(message: CloudEvent):
    print(f"Received Message {message.id} with data: {message.data}")

Run with

eventiq run app:service --log-level=info

Watching for changes

eventiq run app:service --log-level=info --reload=.

Testing

StubBroker class is provided as in memory replacement for running unit tests

import os


def get_broker(**kwargs):
    if os.getenv('ENV') == 'TEST':
        from eventiq.backends.stub import StubBroker
        return StubBroker()
    else:
        from eventiq.backends.rabbitmq import RabbitmqBroker
        return RabbitmqBroker(**kwargs)

broker = get_broker()

Furthermore, subscribers are just regular python coroutines, so it's possible to test them simply by invocation

# main.py
@service.subscribe(topic="test.topic")
async def my_subscriber(message: CloudEvent):
    return 42

# tests.py
from main import my_subscriber

async def test_my_subscriber():
    result = await my_subscriber(None)
    assert result == 42

CLI

Getting help:

eventiq --help

Installing shell autocompletion:

eventiq --install-completion [bash|zsh|fish|powershell|pwsh]

Basic commands

  • run - run service
  • docs - generate AsyncAPI docs
  • send - send message to broker

Metadata

Release files for eventiq 0.3.0rc0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eventiq 0.3.0rc0
File Size Uploaded Provenance Actions
eventiq-0.3.0rc0.tar.gz 31.6 kB Without provenance Details for eventiq-0.3.0rc0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for eventiq 0.3.0rc0
File Interpreter ABI Platform Actions
eventiq-0.3.0rc0-py3-none-any.whl Python 3 none any Details for eventiq-0.3.0rc0-py3-none-any.whl

Total release size: 71.6 kB

Release files / eventiq-0.3.0rc0.tar.gz

Download URL eventiq-0.3.0rc0.tar.gz
Size 31.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f282279706416b6b11f63282e8a02b5260fa932d357de92ac75864c53f3a533f
BLAKE2b-256 checksum
How to use checksums
72a6c6a64809e2926b693679bef3a6baad8fedd1b5611a1f4e7ea33009bea42a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.4

Release files / eventiq-0.3.0rc0-py3-none-any.whl

Download URL eventiq-0.3.0rc0-py3-none-any.whl
Size 40.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77ed159e301d876caabdbbe0d630029cdeb69f8cb65e63d78edb49e219e3076a
BLAKE2b-256 checksum
How to use checksums
7718389e34283bf42c4786762f4afb39fceed249054a60d952a4cb7655edf903
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.4

Security for eventiq 0.3.0rc0

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.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page