FlowControllerSystem Components
FlowController
Role: The base class for all flow controllers. It is the only type in this system.
Responsibilities:
- Registers its command handler for its
Domainon the command bus duringInit. - Defines the abstract
HandleCommandmethod that subclasses implement. - Exposes the abstract
Domainproperty that identifies the controller's domain.
Lifecycle:
- A subclass is constructed in
InitializationManager.RegisterSystems, typically throughSafeRegister. InitializationRegistrystores it as a sync initializable, because it does not implement the event receiver interface.InitializationOrchestratorcallsInit, which registersHandleCommandwith the command bus.- Commands addressed to the controller's domain are delivered to
HandleCommand.
Subclasses (implemented by consuming projects)
Each project creates one subclass per domain. A subclass:
- Overrides
Domainto return itsDomainvalue. - Implements
HandleCommandto process commands for that domain. - Overrides
Initonly when extra setup is needed. It must callbase.Init(). - Obtains other buses, such as the query bus, through
ServiceLocatorif needed. The base class does not provide them.
Interaction with dependency classes
| Class | Interaction |
|---|---|
InitializationManager | Creates the controller through SafeRegister during RegisterSystems. Initializes ServiceLocator before that call. |
InitializationRegistry | Stores the controller in the sync initializables list. |
InitializationOrchestrator | Calls Init during the sync initialization phase. |
ServiceLocator | Provides the bus registry from which the CommandBus is obtained. |
CommandBus | Receives the Register(Domain, HandleCommand) call and routes commands by TargetDomain. |
ICommand | The payload type passed to HandleCommand. |
Domain (enum) | The routing key that identifies each controller. |