1 comments

  • e1-m 7 hours ago
    Hey folks, quick update! I just shipped a new version of [*Dispytch*](https://github.com/e1-m/dispytch) — async Python framework for building event-driven services.

    # What Dispytch Does

    Dispytch makes it easy to build services that react to events — whether they're coming from Kafka, RabbitMQ, Redis or some other broker. You define event types as Pydantic models and wire up handlers with dependency injection. Dispytch handles validation, retries, and routing out of the box, so you can focus on the logic.

    # Comparison

    |Framework|Focus|Notes| |:-|:-|:-| |Celery|Task queues|Great for backgroud processing| |Faust|Kafka streams|Powerful, but streaming-centric| |Nameko|RPC services|Sync-first, heavy| |FastAPI|HTTP APIs|Not for event processing| |FastStream|Stream pipelines|Built around streams—great for data pipelines.| |*Dispytch*|Event handling|Event-centric and reactive, designed for clear event-driven services.|

    # Quick API Example

    # Handler

        user_events.handler(topic='user_events', event='user_registered')
        async def handle_user_registered(
                event: Event[UserCreatedEvent],
                user_service: Annotated[UserService, Dependency(get_user_service)]
        ):
            user = event.body.user
            timestamp = event.body.timestamp
        
            print(f"[User Registered] {user.id} - {user.email} at {timestamp}")
        
            await user_service.do_smth_with_the_user(event.body.user)
    
    # Emitter

        async def example_emit(emitter):
           await emitter.emit(
               UserRegistered(
                   user=User(
                       id=str(uuid.uuid4()),
                       email="example@mail.com",
                       name="John Doe",
                   ),
                   timestamp=int(datetime.now().timestamp()),
               )
           )
    
    # What’s New?

    *Redis Pub/Sub support* You can now plug Redis into Dispytch and start consuming events without spinning up Kafka or RabbitMQ. Perfect for lightweight setups.

    *Dynamic Topics* Handlers can now use topic segments as function arguments — e.g., match `"user.{user_id}.notification"` and get `user_id` injected automatically. Clean and type-safe thanks to Pydantic validation.

    Try it out:

        uv add dispytch
    
     Docs and examples in the repo: [https://github.com/e1-m/dispytch](https://github.com/e1-m/dispytch)
    
    Feedback, bug reports, feature requests — all welcome. Still early, still evolving

    Thanks for checking it out!