Bootstrap¶
Overview¶
-
Request Mediator
Standard mediator for commands and queries with automatic handler resolution.
-
Streaming Request Mediator
For incremental processing and Server-Sent Events (SSE) support.
-
Event Mediator
For processing events from message brokers like Kafka and RabbitMQ.
-
Message Brokers
Configure Kafka, RabbitMQ, and custom brokers for event publishing.
-
Middlewares
Request interception and modification with custom middleware support.
-
DI Containers
Dependency injection configuration and container setup.
-
Advanced Configuration
Combining all options and manual setup for complex scenarios.
The bootstrap utilities simplify the initial configuration of your CQRS application. They automatically set up:
- Dependency Injection Container — Resolves handlers and their dependencies (see Dependency Injection)
- Request Mapping — Maps commands and queries to their handlers (see Request Handlers)
- Event Mapping — Maps domain events to their handlers (see Event Handling)
- Message Broker — Configures event publishing (see Event Producing)
- Middlewares — Adds logging and custom middlewares
- Event Processing — Configures parallel event processing
Getting Started
If you're new to python-cqrs, start here! Bootstrap is the foundation for all other features. After configuring bootstrap, proceed to Request Handlers to learn how to create command and query handlers.
Navigation
Use the navigation menu on the left to explore different mediator types and configuration options. Each section covers a specific aspect of bootstrap configuration.
Mediator Types¶
The python-cqrs package provides three types of mediators:
| Mediator Type | Use Case | Bootstrap Function |
|---|---|---|
RequestMediator |
Standard commands and queries | bootstrap.bootstrap() |
StreamingRequestMediator |
Streaming requests with incremental results | bootstrap.bootstrap_streaming() |
EventMediator |
Processing events from message brokers | bootstrap.bootstrap() (events module) |
Mediator Comparison
Each mediator type has its own bootstrap function and configuration options. Choose based on your use case:
- RequestMediator: Most common, handles standard CQRS operations
- StreamingRequestMediator: For real-time progress updates (SSE, WebSockets)
- EventMediator: For consuming events from Kafka/RabbitMQ
When to use each mediator?
- RequestMediator: Use for standard HTTP API endpoints (GET, POST, PUT, DELETE)
- StreamingRequestMediator: Use when you need to stream results back to clients (file processing, batch operations)
- EventMediator: Use in FastStream consumers to process events from message brokers
Quick Navigation¶
- Request Mediator — Standard mediator for commands and queries
- Streaming Request Mediator — For incremental processing and SSE
- Event Mediator — For processing events from message brokers
- Message Brokers — Kafka, RabbitMQ, and custom brokers
- Middlewares — Request interception and modification
- DI Containers — Dependency injection configuration
- Advanced Configuration — Combining all options and manual setup