Module dendrite::axon_utils
source · Expand description
§Axon Utilities
Module axon_utils
exports items that can be used to create a complete Event Sourced CQRS
application that uses AxonServer as an event store.
The whole back-end can be packaged as a single application, but when growing load or complexity
demands it, aspects can be taken out and converted to microservices that can be scaled horizontally.
The basic parts of a dendrite application are:
- Command API — accepts commands on a gRPC API and forwards them (again over gRPC to AxonServer)
- Command worker — subscribes to commands, verifies them against the command projection and sends emitted events to AxonServer
- Event processor — subscribes to events and builds a query model from them (there are likely to be multiple query models for a single application)
- Query API — accepts queries on a gRPC API and forwards them (again over gRPC to AxonServer)
- Query processor — subscribes to queries, executes them against a query model and pass back the results
Structs§
- The complete definition of an aggregate.
- A handle for AxonServer.
- Struct that can be returned by a command handler to supply both the events that have to be emitted and the response to the caller.
- Carries the result of a query from handler to processor.
- Describes a serialized object
- Concrete struct that implements
AggregateRegistry
. - Concrete struct that implements the
HandlerRegistry
trait.
Enums§
Traits§
- Trait that needs to be implemented by the aggregate registry.
- Describes a
Message
that is applicable to a particular projection type. - Describes a
Message
that is asynchronously applicable to a particular projection type. - Trait that is implemented by an object that can be used to send commands to AxonServer.
- Describes a registry for handlers for a particular type projection (or context) and a particular return type. I tried to make it possible to pass an
async fn
directly to parameterhandler
, but the return type after desugaring is unnameable (https://internals.rust-lang.org/t/naming-the-return-type-of-an-async-function/10085). So it has to be wrapped in a closure thatBox::pin
s the return value, like this: - Marker trait that describes the context for a query handler.
- Trait that is implemented by an object that can be used to send queries to AxonServer.
- Describes a token store.
- Describes a message that can be serialized to a mutable
Vec<u8>
.
Functions§
- Converts a
prost::Message
to an AxonSerializedObject
. - Subscribes to commands, verifies them against the command projection and sends emitted events to AxonServer.
- Creates a new aggregate definition as needed by function
command_worker
. - Adds an event that can be applied to the command projection to be emitted to the result of a command handler.
- Creates a struct that can be returned by a command handler to supply the events that have to be emitted.
- Creates a struct that can be returned by a command handler to supply both the events that have to be emitted and the response to the caller.
- Creates an empty aggregate registry that can be populated with
AggregateHandle
s (most likely:AggregateDefinition
s). - Creates an empty handler registry for a type of projection and a type of return values that can be populated with SubscriptionHandles.
- Subscribes to events and builds a query model from them.
- Polls AxonServer until it is available and ready.
- Subscribes to commands, verifies them against the command projection and sends emitted events to AxonServer.
- Fetch all events for a given aggregate.
- Subscribes to queries, executes them against a query model and pass back the results.
- Polls AxonServer until it is available and ready.