5 releases (breaking)
0.6.0 | Feb 21, 2024 |
---|---|
0.4.0 | Feb 3, 2022 |
0.3.0 | Jan 26, 2022 |
0.2.0 | Jan 23, 2022 |
0.1.0 | Jan 22, 2022 |
#502 in Rust patterns
Used in dddk_security
92KB
2K
SLoC
4dk-core
The core project implements the primary concept of this framework.
It implements the entites : Command
, Event
and Query
.
Command
Command
A Command
is an object which triggers a usecase of type CommandHandler
. It is an order sent to the system. The transaction will result a list of Event
.
A Command
is dispatched to the correct handler trough a CommandBus
.
CommandBus
A CommandBus
valids the following trait fn dispatch(command: &Command) -> Vec<Box<dyn Event>>
.
This project proposes the following commandbus:
CommandDispatcher
: itsnew
factory takes in entry a vectorVec<Arc<Box CommandHandlerInBus>>
ofCommandHandlerInBus
. This bus dispatchesCommand
to correctCommandHandler
.
You can find in samples different bus composition.
Event
An Event
is an object returned by a CommandHandler
. An Event
is a result of a business transaction. It could trigger usecases of type EventHandler
An Event
is dispatched to its associates handlers through an EventBus
.
Query
A Query
is an object which triggers a usecase of type QueryHandler
. It is a question asked to the system. A Response
is returned from a QueryHandler
.
QueryBus
An EventBus
valids the following trait fn dispatch(query: &Query) -> Vec<Box<dyn Response>>
.
This project proposes the following querybus:
QueryDispatcher
: itsnew
factory takes in entry a vectorVec<Arc<Box QueryHandlerInBus>>
ofQueryHandlerInBus
. This bus dispatchesQuery
to its correctQueryHandler
.
Dependencies
~87KB