LCOV - code coverage report
Current view: top level - Cqrs/Domain - ISaga.cs Hit Total Coverage
Test: doc-coverage.info Lines: 0 3 0.0 %
Date: 2017-07-26

          Line data    Source code
       1             : #region Copyright
       2             : // // -----------------------------------------------------------------------
       3             : // // <copyright company="cdmdotnet Limited">
       4             : // //   Copyright cdmdotnet Limited. All rights reserved.
       5             : // // </copyright>
       6             : // // -----------------------------------------------------------------------
       7             : #endregion
       8             : 
       9             : using System;
      10             : using System.Collections.Generic;
      11             : using System.Runtime.Serialization;
      12             : using Cqrs.Commands;
      13             : using Cqrs.Events;
      14             : 
      15             : namespace Cqrs.Domain
      16             : {
      17             :         /// <summary>
      18             :         /// An independent component that reacts to domain <see cref="IEvent{TAuthenticationToken}"/> in a cross-<see cref="IAggregateRoot{TAuthenticationToken}"/>, eventually consistent manner. Time can also be a trigger. A <see cref="Saga{TAuthenticationToken}"/> can sometimes be purely reactive, and sometimes represent workflows.
      19             :         /// 
      20             :         /// From an implementation perspective, a <see cref="Saga{TAuthenticationToken}"/> is a state machine that is driven forward by incoming <see cref="IEvent{TAuthenticationToken}"/> (which may come from many <see cref="AggregateRoot{TAuthenticationToken}"/> or other <see cref="Saga{TAuthenticationToken}"/>). Some states will have side effects, such as sending <see cref="ICommand{TAuthenticationToken}"/>, talking to external web services, or sending emails.
      21             :         /// </summary>
      22             :         /// <remarks>
      23             :         /// Isn't a <see cref="Saga{TAuthenticationToken}"/> just leaked domain logic?
      24             :         /// No.
      25             :         /// A <see cref="Saga{TAuthenticationToken}"/> can doing things that no individual <see cref="AggregateRoot{TAuthenticationToken}"/> can sensibly do. Thus, it's not a logic leak since the logic didn't belong in an <see cref="AggregateRoot{TAuthenticationToken}"/> anyway. Furthermore, we're not breaking encapsulation in any way, since <see cref="Saga{TAuthenticationToken}"/> operate with <see cref="ICommand{TAuthenticationToken}"/> and <see cref="IEvent{TAuthenticationToken}"/>, which are part of the public API.
      26             :         /// 
      27             :         /// How can I make my <see cref="Saga{TAuthenticationToken}"/> react to an <see cref="IEvent{TAuthenticationToken}"/> that did not happen?
      28             :         /// The <see cref="Saga{TAuthenticationToken}"/>, besides reacting to domain <see cref="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.
      29             :         /// 
      30             :         /// How does the <see cref="Saga{TAuthenticationToken}"/> interact with the write side?
      31             :         /// By sending an <see cref="ICommand{TAuthenticationToken}"/> to it.
      32             :         /// </remarks>
      33             :         public interface ISaga<TAuthenticationToken>
      34             :         {
      35             :                 [DataMember]
      36             :                 Guid Id { get; }
      37             : 
      38             :                 [DataMember]
      39             :                 int Version { get; }
      40             : 
      41           0 :                 IEnumerable<ISagaEvent<TAuthenticationToken>> GetUncommittedChanges();
      42             : 
      43           0 :                 void MarkChangesAsCommitted();
      44             : 
      45           0 :                 void LoadFromHistory(IEnumerable<ISagaEvent<TAuthenticationToken>> history);
      46             :         }
      47             : }

Generated by: LCOV version 1.10