Expand description
§Présage \pʁe.zaʒ\
Présage is a Rust lightweight library for designing event-based systems.
§Concepts
In an event-based systems, anything that can happen is modeled with an Event. Business entities are designed with aggregates, that are atomically modified with events.
Présage is freely inspired by concepts like domain-driven design or command-query responsibility segregation, but tries to be agnostic by making as few assumptions as possible. Specifically, it does not tie you to any persistence approach.
§Command bus
The command bus is the main entry point when using présage. It takes a context and a command to execute. The resulting events are persisted, then any matching event handler is executed. Those event handlers can return new commands which are also executed. The process continues as long as events and commands are issued.
§Context
Command handlers and event handlers are executed within a mutable context. This context is specific to your application and contains whatever is necessary for the execution of the handlers. For instance, it can contain a connection to a database.
§Features
The derive feature, which is enabled by default, provides derive macros for Event,
AggregateEvent and Command, as well as attribute macros to easily create
command handlers and event handlers.
Macros§
- commands
- Creates a new Commands containing the commands passed as arguments.
- events
- Creates a new Events containing the events passed as arguments.
Structs§
- Boxed
Command - A command that has been boxed to be dispatched.
- Command
Bus - Executes a command and handles issued events.
- Commands
- Wrapper for a Vec of boxed commands.
- Configuration
- A configuration for a CommandBus.
- Events
- Wrapper for a Vec of serialized events.
- Id
- Wrapper type for the id of an aggregate.
- Serialized
Event - An event that has been serialized to be issued by a command.
Enums§
- Error
- Errors that can occur during the execution of a command by a CommandBus.
Traits§
- Aggregate
- An aggregate represent a business entity that can evolve during the system execution.
- Aggregate
Event - An Event that creates, updates, or deletes an aggregate.
- Command
- A request to modify the system.
- Command
Handler - Handles a command and produces events.
- Event
- An event represent something that happened in the past.
- Event
Handler - Reacts to issued events.
- Event
Writer - Persists the modifications of events.
Attribute Macros§
- async_
trait derive - command_
handler derive - Creates an CommandHandler from a function.
- event_
handler derive - Creates an EventHandler from a function.
Derive Macros§
- Aggregate
Event derive - Derives the AggregateEvent trait.
- Command
derive - Derives the Command trait.
- Event
derive - Derives the Event trait.