![]() |
CQRS.NET
4.0
A lightweight enterprise Function as a Service (FaaS) framework to write function based serverless and micro-service applications in hybrid multi-datacentre, on-premise and Azure environments.
|
An independent component that reacts to domain IEvent<TAuthenticationToken> in a cross-IAggregateRoot<TAuthenticationToken>, eventually consistent manner. Time can also be a trigger. A Saga<TAuthenticationToken> can sometimes be purely reactive, and sometimes represent workflows. More...
Public Member Functions | |
virtual IEnumerable< ISagaEvent< TAuthenticationToken > > | GetUncommittedChanges () |
Get all applied changes that haven't yet been committed. More... | |
virtual void | MarkChangesAsCommitted () |
Mark all applied changes as committed, increment Version and flush the internal collection of changes. More... | |
virtual void | LoadFromHistory (IEnumerable< ISagaEvent< TAuthenticationToken >> history) |
Apply all the events in history using event replay to this instance. More... | |
virtual IEnumerable< ICommand< TAuthenticationToken > > | GetUnpublishedCommands () |
Get all pending commands that haven't yet been published yet. More... | |
virtual void | MarkCommandsAsPublished () |
Mark all published commands as published and flush the internal collection of commands. More... | |
Protected Member Functions | |
Saga () | |
A constructor for the Cqrs.Domain.Factories.IAggregateFactory More... | |
virtual void | Initialise () |
Initialise any properties More... | |
Saga (IDependencyResolver dependencyResolver, ILogger logger) | |
A constructor for the Cqrs.Domain.Factories.IAggregateFactory More... | |
Saga (IDependencyResolver dependencyResolver, ILogger logger, Guid rsn) | |
A constructor for the Cqrs.Domain.Factories.IAggregateFactory More... | |
virtual void | QueueCommand (ICommand< TAuthenticationToken > command) |
Queue the provided command for publishing. More... | |
virtual void | ApplyChange (ISagaEvent< TAuthenticationToken > @event) |
Call the "Apply" method with a signature matching the provided event without using event replay to this instance. More... | |
virtual void | ApplyChange (IEvent< TAuthenticationToken > @event) |
Calls the "SetId" method dynamically if the method exists, then calls ApplyChange(Cqrs.Events.ISagaEvent<TAuthenticationToken>) More... | |
virtual void | SetId (ISagaEvent< TAuthenticationToken > sagaEvent) |
Sets the IEvent<TAuthenticationToken>.Id from ISagaEvent<TAuthenticationToken>.Event back onto sagaEvent . More... | |
virtual void | ApplyChanges (IEnumerable< ISagaEvent< TAuthenticationToken >> events) |
Call the "Apply" method with a signature matching each ISagaEvent<TAuthenticationToken> in the provided events without using event replay to this instance. More... | |
virtual void | ApplyChanges (IEnumerable< IEvent< TAuthenticationToken >> events) |
Calls the "SetId" method dynamically if the method exists on the first IEvent<TAuthenticationToken> in the provided events , then calls ApplyChanges(System.Collections.Generic.IEnumerable<Cqrs.Events.ISagaEvent<TAuthenticationToken>>) More... | |
Properties | |
Guid | Rsn [get] |
The identifier of this ISaga<TAuthenticationToken>. More... | |
Guid | Id [get, protected set] |
The identifier of this ISaga<TAuthenticationToken>. More... | |
int | Version [get, protected set] |
The current version of this ISaga<TAuthenticationToken>. More... | |
ICommandPublisher< TAuthenticationToken > | CommandPublisher [get] |
Gets or set the ICommandPublisher<TAuthenticationToken>. More... | |
IDependencyResolver | DependencyResolver [get] |
Gets or set the IDependencyResolver. More... | |
ILogger | Logger [get] |
Gets or set the ILogger. More... | |
![]() | |
Guid | Id [get] |
The identifier of the ISaga<TAuthenticationToken>. More... | |
int | Version [get] |
The current version of this ISaga<TAuthenticationToken>. More... | |
An independent component that reacts to domain IEvent<TAuthenticationToken> in a cross-IAggregateRoot<TAuthenticationToken>, eventually consistent manner. Time can also be a trigger. A Saga<TAuthenticationToken> can sometimes be purely reactive, and sometimes represent workflows.
From an implementation perspective, a Saga<TAuthenticationToken> is a state machine that is driven forward by incoming IEvent<TAuthenticationToken> (which may come from many AggregateRoot<TAuthenticationToken> or other Saga<TAuthenticationToken>). Some states will have side effects, such as sending ICommand<TAuthenticationToken>, talking to external web services, or sending emails.
Isn't a Saga<TAuthenticationToken> just leaked domain logic? No. A Saga<TAuthenticationToken> can doing things that no individual AggregateRoot<TAuthenticationToken> can sensibly do. Thus, it's not a logic leak since the logic didn't belong in an AggregateRoot<TAuthenticationToken> anyway. Furthermore, we're not breaking encapsulation in any way, since Saga<TAuthenticationToken> operate with ICommand<TAuthenticationToken> and IEvent<TAuthenticationToken>, which are part of the public API.
How can I make my Saga<TAuthenticationToken> react to an IEvent<TAuthenticationToken> that did not happen? The Saga<TAuthenticationToken>, besides reacting to domain IEvent<TAuthenticationToken>, can be "woken up" by recurrent internal alarms. Implementing such alarms is easy. See cron in Unix, or triggered WebJobs in Azure for examples.
How does the Saga<TAuthenticationToken> interact with the write side? By sending an ICommand<TAuthenticationToken> to it.