eventiq


Nameeventiq JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/performancemedia/eventiq
SummaryCloud native framework for building event driven applications in Python.
upload_time2024-02-26 09:08:18
maintainer
docs_urlNone
authorRadzim Kowalow
requires_python>=3.9,<4.0
licenseApache-2.0
keywords framework asyncio microservice event-driven
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
<img src="https://performancemedia.github.io/eventiq/assets/logo.svg" style="width: 250px">

</p>
<p align="center">
<em>Cloud native framework for building event driven applications in Python</em>
</p>

![Tests](https://github.com/performancemedia/eventiq/workflows/Test/badge.svg)
![Build](https://github.com/performancemedia/eventiq/workflows/Publish/badge.svg)
![License](https://img.shields.io/github/license/performancemedia/eventiq)
![Python](https://img.shields.io/pypi/pyversions/eventiq)
![Format](https://img.shields.io/pypi/format/eventiq)
![PyPi](https://img.shields.io/pypi/v/eventiq)
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)

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

---
Version: 0.2.0

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](https://cloudevents.io/) format is used.
Service can be run as standalone processes, or included into starlette (e.g. FastAPI) applications.

## Installation

```shell
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:

- [Celery](https://docs.celeryq.dev/en/stable/getting-started/introduction.html)
- [Dramatiq](https://dramatiq.io/)
- [Huey](https://huey.readthedocs.io/en/latest/)
- [arq](https://arq-docs.helpmanual.io/)

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


```python
# 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

```shell
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](http://supervisord.org/),
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)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/performancemedia/eventiq",
    "name": "eventiq",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "framework,asyncio,microservice,event-driven",
    "author": "Radzim Kowalow",
    "author_email": "radzim.kowalow@performance-media.pl",
    "download_url": "https://files.pythonhosted.org/packages/a6/b0/5515bb1eb56d997791a6881a8c74e0034745d536b4a3ec5966ff8833a5a4/eventiq-0.2.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n<img src=\"https://performancemedia.github.io/eventiq/assets/logo.svg\" style=\"width: 250px\">\n\n</p>\n<p align=\"center\">\n<em>Cloud native framework for building event driven applications in Python</em>\n</p>\n\n![Tests](https://github.com/performancemedia/eventiq/workflows/Test/badge.svg)\n![Build](https://github.com/performancemedia/eventiq/workflows/Publish/badge.svg)\n![License](https://img.shields.io/github/license/performancemedia/eventiq)\n![Python](https://img.shields.io/pypi/pyversions/eventiq)\n![Format](https://img.shields.io/pypi/format/eventiq)\n![PyPi](https://img.shields.io/pypi/v/eventiq)\n[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)\n\n*Note: This package is under active development and is not recommended for production use*\n\n---\nVersion: 0.2.0\n\nDocumentation: https://performancemedia.github.io/eventiq/\n\nRepository: https://github.com/performancemedia/eventiq\n\n---\n## About\n\nThe package utilizes `anyio` and `pydantic` as the only required dependencies.\nFor messages [Cloud Events](https://cloudevents.io/) format is used.\nService can be run as standalone processes, or included into starlette (e.g. FastAPI) applications.\n\n## Installation\n\n```shell\npip install eventiq\n```\n\n## Multiple broker support (in progress)\n\n- Stub (in memory using `asyncio.Queue` for PoC, local development and testing)\n- NATS (with JetStream)\n- Redis Pub/Sub\n- Kafka\n- Rabbitmq\n- Google Cloud PubSub\n- And more coming\n\n## Optional Dependencies\n  - `cli` - `typer`\n  - broker of choice: `nats`, `kafka`, `rabbitmq`, `redis`, `pubsub`\n  - custom message serializers: `msgpack`, `orjson`\n  - `prometheus` - Metric exposure via `PrometheusMiddleware`\n  - `opentelemetry` - tracing support\n\n## Motivation\n\nPython has many \"worker-queue\" libraries and frameworks, such as:\n\n- [Celery](https://docs.celeryq.dev/en/stable/getting-started/introduction.html)\n- [Dramatiq](https://dramatiq.io/)\n- [Huey](https://huey.readthedocs.io/en/latest/)\n- [arq](https://arq-docs.helpmanual.io/)\n\nHowever, those libraries don't provide a pub/sub pattern, useful for creating\nevent driven and loosely coupled systems. Furthermore, the majority of those libraries\ndo not support `asyncio`. This is why this project was born.\n\n## Basic usage\n\n\n```python\n# main.py\nimport asyncio\nfrom eventiq import Service, CloudEvent, Middleware\nfrom eventiq.backends.nats.broker import JetStreamBroker\n\n\nclass SendMessageMiddleware(Middleware):\n    async def after_broker_connect(self, broker: \"Broker\") -> None:\n        print(f\"After service start, running with {broker}\")\n        await asyncio.sleep(10)\n        for i in range(100):\n            await broker.publish(\"test.topic\", data={\"counter\": i})\n        print(\"Published event(s)\")\n\nbroker = JetStreamBroker(url=\"nats://localhost:4222\")\nbroker.add_middleware(SendMessageMiddleware())\n\nservice = Service(name=\"example-service\", broker=broker)\n\n@service.subscribe(\"test.topic\")\nasync def example_run(message: CloudEvent):\n    print(f\"Received Message {message.id} with data: {message.data}\")\n\n```\n## Running the service\n\n```shell\neventiq run main:service\n```\n\n## Scaling\n\nEach message is load-balanced (depending on broker) between all service instances with the same `name`.\nTo scale number of processes you can use containers (docker/k8s), [supervisor](http://supervisord.org/),\nor web server like gunicorn.\n\n## Features\n\n- Modern, `asyncio` based python 3.8+ syntax\n- Minimal dependencies, only `anyio` and `pydantic` are required\n- Automatic message parsing based on type annotations (like FastAPI)\n- Code hot-reload\n- Highly scalable: each service can process hundreds of tasks concurrently,\n    all messages are load balanced between all instances by default\n- Resilient - at least once delivery for all messages by default\n- Customizable & pluggable message encoders (json, msgpack, custom)\n- Multiple broker support (Nats, Kafka, Rabbitmq, Redis, PubSub, and more coming)\n- Easily extensible via Middlewares and Plugins\n- Cloud Events standard as base message structure (no more python specific `*args` and `**kwargs` in messages)\n- AsyncAPI documentation generation from code\n- Twelve factor app approach - stdout logging, configuration through environment variables\n- Out-of-the-box integration with Prometheus (metrics) and OpenTelemetry (tracing)\n- Application bootstrap via `.yaml` file (see examples/configuration)\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Cloud native framework for building event driven applications in Python.",
    "version": "0.2.0",
    "project_urls": {
        "Documentation": "https://performancemedia.github.io/eventiq/",
        "Homepage": "https://github.com/performancemedia/eventiq",
        "Repository": "https://github.com/performancemedia/eventiq"
    },
    "split_keywords": [
        "framework",
        "asyncio",
        "microservice",
        "event-driven"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ab528221b2e4533b3ed45bc7ebff86471685403aaa30b995dd8bc9ccb0c3194e",
                "md5": "d6bb570a73b2459b408d9f8254c66ef1",
                "sha256": "e2f1d6d5142f740f5250c08cb9c461f69dc13d06e106341b80198baf1b7ff3b1"
            },
            "downloads": -1,
            "filename": "eventiq-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d6bb570a73b2459b408d9f8254c66ef1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 64916,
            "upload_time": "2024-02-26T09:08:16",
            "upload_time_iso_8601": "2024-02-26T09:08:16.759875Z",
            "url": "https://files.pythonhosted.org/packages/ab/52/8221b2e4533b3ed45bc7ebff86471685403aaa30b995dd8bc9ccb0c3194e/eventiq-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a6b05515bb1eb56d997791a6881a8c74e0034745d536b4a3ec5966ff8833a5a4",
                "md5": "0418cca380baea2403dd4fe3887a39e2",
                "sha256": "6777577baaf6d0e2e085e6c29ba1dd4fe159e83a1fa811cc3272d3ef4f28631e"
            },
            "downloads": -1,
            "filename": "eventiq-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0418cca380baea2403dd4fe3887a39e2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 44253,
            "upload_time": "2024-02-26T09:08:18",
            "upload_time_iso_8601": "2024-02-26T09:08:18.331287Z",
            "url": "https://files.pythonhosted.org/packages/a6/b0/5515bb1eb56d997791a6881a8c74e0034745d536b4a3ec5966ff8833a5a4/eventiq-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-26 09:08:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "performancemedia",
    "github_project": "eventiq",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "eventiq"
}
        
Elapsed time: 0.18962s