#ddd #ddd-cqrs-framework #hexagonal-arch #events

dddk_core

Tactical DDD framework based on command_bus, event_bus and query_bus. It offers annex feature such as authorization, logging ...

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

Apache-2.0

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: its new factory takes in entry a vector Vec<Arc<Box CommandHandlerInBus>> of CommandHandlerInBus. This bus dispatches Command to correct CommandHandler.



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: its new factory takes in entry a vector Vec<Arc<Box QueryHandlerInBus>> of QueryHandlerInBus. This bus dispatches Query to its correct QueryHandler.

Dependencies

~87KB