Documentation Coverage Report
Current view: top level - Cqrs/Domain - ISaga.cs Hit Total Coverage
Version: 2.2 Artefacts: 5 5 100.0 %
Date: 2018-08-07 15:04:50

          Line data    Source code
       1             : #region Copyright
       2             : // // -----------------------------------------------------------------------
       3             : // // <copyright company="Chinchilla Software Limited">
       4             : // //   Copyright Chinchilla Software 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             :                 /// <summary>
      36             :                 /// The identifier of the <see cref="ISaga{TAuthenticationToken}"/>.
      37             :                 /// </summary>
      38             :                 [DataMember]
      39             :                 Guid Id { get; }
      40             : 
      41             :                 /// <summary>
      42             :                 /// The current version of this <see cref="ISaga{TAuthenticationToken}"/>.
      43             :                 /// </summary>
      44             :                 [DataMember]
      45             :                 int Version { get; }
      46             : 
      47             :                 /// <summary>
      48             :                 /// Get all applied changes that haven't yet been committed.
      49             :                 /// </summary>
      50           1 :                 IEnumerable<ISagaEvent<TAuthenticationToken>> GetUncommittedChanges();
      51             : 
      52             :                 /// <summary>
      53             :                 /// Mark all applied changes as committed, increment <see cref="Version"/> and flush the internal collection of changes.
      54             :                 /// </summary>
      55           1 :                 void MarkChangesAsCommitted();
      56             : 
      57             :                 /// <summary>
      58             :                 /// Apply all the <see cref="IEvent{TAuthenticationToken}">events</see> in <paramref name="history"/>
      59             :                 /// using event replay to this instance.
      60             :                 /// </summary>
      61           1 :                 void LoadFromHistory(IEnumerable<ISagaEvent<TAuthenticationToken>> history);
      62             : 
      63             :                 /// <summary>
      64             :                 /// Get all pending commands that haven't yet been published yet.
      65             :                 /// </summary>
      66           1 :                 IEnumerable<ICommand<TAuthenticationToken>> GetUnpublishedCommands();
      67             : 
      68             :                 /// <summary>
      69             :                 /// Mark all published commands as published and flush the internal collection of commands.
      70             :                 /// </summary>
      71           1 :                 void MarkCommandsAsPublished();
      72             :         }
      73             : }

Generated by: LCOV version 1.12