Skip to main content

Cloud native framework for building event driven applications in Python

Tests Build License Python Format PyPi security: bandit Ruff

Note: This package is under active development and is not recommended for production use


Version: 0.2.1

Documentation: https://performancemedia.github.io/eventiq/

Repository: https://github.com/performancemedia/eventiq


About

The package utilizes anyio and pydantic as the only required dependencies. For messages Cloud Events format is used. Service can be run as standalone processes, or included into starlette (e.g. FastAPI) applications.

Installation

pip install eventiq

Multiple broker support (in progress)

  • Stub (in memory using asyncio.Queue for PoC, local development and testing)
  • NATS (with JetStream)
  • Redis Pub/Sub
  • Kafka
  • Rabbitmq
  • Google Cloud PubSub
  • And more coming

Optional Dependencies

  • cli - typer
  • broker of choice: nats, kafka, rabbitmq, redis, pubsub
  • custom message serializers: msgpack, orjson
  • prometheus - Metric exposure via PrometheusMiddleware
  • opentelemetry - tracing support

Motivation

Python has many "worker-queue" libraries and frameworks, such as:

However, those libraries don't provide a pub/sub pattern, useful for creating event driven and loosely coupled systems. Furthermore, the majority of those libraries do not support asyncio. This is why this project was born.

Basic usage

# main.py
import asyncio
from eventiq import Service, CloudEvent, Middleware
from eventiq.backends.nats.broker import JetStreamBroker


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

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

service = Service(name="example-service", broker=broker)

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

Running the service

eventiq run main:service

Scaling

Each message is load-balanced (depending on broker) between all service instances with the same name. To scale number of processes you can use containers (docker/k8s), supervisor, or web server like gunicorn.

Features

  • Modern, asyncio based python 3.8+ syntax
  • Minimal dependencies, only anyio and pydantic are required
  • Automatic message parsing based on type annotations (like FastAPI)
  • 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, msgpack, custom)
  • Multiple broker support (Nats, Kafka, Rabbitmq, Redis, PubSub, and more coming)
  • Easily extensible via Middlewares and Plugins
  • 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
  • Out-of-the-box integration with Prometheus (metrics) and OpenTelemetry (tracing)
  • Application bootstrap via .yaml file (see examples/configuration)

Metadata

Release files for eventiq 0.2.1

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.2.1
File Size Uploaded Provenance Actions
eventiq-0.2.1.tar.gz 44.3 kB Without provenance Details for eventiq-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 109.2 kB

Release files / eventiq-0.2.1.tar.gz

Download URL eventiq-0.2.1.tar.gz
Size 44.3 kB
Tags Source
SHA-256 checksum
How to use checksums
139214bdb6dcd70c424cb1b6520493c72b008a3c0aeabd75e5f2eb89795e6870
BLAKE2b-256 checksum
How to use checksums
4eaf9b48e83421821f4e3d4d2a55a81b5f51c2f5a646372d533eba113be0a889
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / eventiq-0.2.1-py3-none-any.whl

Download URL eventiq-0.2.1-py3-none-any.whl
Size 64.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e660342409bef0579759dac98c2e9170211436e52c22952c81f1749ce29c77f
BLAKE2b-256 checksum
How to use checksums
1dbd1b830393e6dea64e8a832f686e97e9abd1c9cd9da04b42184abd6c8d7ca0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Security for eventiq 0.2.1

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

0.2.1 This release

2 release files No provenance

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