aeventkit: Event-Driven Data Pipelines

2.1.0 · active · verified Fri Apr 17

aeventkit is an active Python library (current version 2.1.0) for building event-driven data pipelines. It leverages Pydantic v2 for robust data validation and AnyIO for asynchronous execution, making it suitable for modern, high-performance applications. The library focuses on clear separation of concerns with publishers, subscribers, and an event bus.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to define a custom Event, create a Publisher and Subscriber, register them with an EventBus, and publish an event. It uses `anyio.run()` to execute the asynchronous main function, which is the standard entry point for aeventkit applications.

import anyio
from aeventkit import Event, EventBus, EventSubscriber, EventPublisher
from pydantic import Field

class MyEvent(Event):
    message: str = Field(..., description="A simple test message")

class MySubscriber(EventSubscriber):
    async def handle(self, event: MyEvent):
        print(f"Subscriber received: {event.message}")

async def main():
    bus = EventBus()
    subscriber = MySubscriber()
    publisher = EventPublisher()

    bus.register_subscriber(subscriber)
    bus.register_publisher(publisher)

    print("Publishing event...")
    await publisher.publish(MyEvent(message="Hello, aeventkit!"))
    await anyio.sleep(0.1) # Give subscriber a moment to process
    print("Event published and potentially handled.")

if __name__ == "__main__":
    anyio.run(main)

view raw JSON →