Documentation Coverage Report
Current view: top level - Akka.Net/Cqrs.Akka/Domain - AkkaSagaRepository.cs Hit Total Coverage
Version: 2.2 Artefacts: 4 4 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.Threading.Tasks;
      11             : using cdmdotnet.Logging;
      12             : using Cqrs.Akka.Events;
      13             : using Cqrs.Commands;
      14             : using Cqrs.Domain;
      15             : using Cqrs.Domain.Factories;
      16             : using Cqrs.Events;
      17             : 
      18             : namespace Cqrs.Akka.Domain
      19             : {
      20             :         /// <summary>
      21             :         /// A <see cref="SagaRepository{TAuthenticationToken}"/> that is safe to use within Akka.NET
      22             :         /// </summary>
      23             :         /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of authentication token.</typeparam>
      24             :         public class AkkaSagaRepository<TAuthenticationToken>
      25             :                 : SagaRepository<TAuthenticationToken>
      26             :                 , IAkkaSagaRepository<TAuthenticationToken>
      27           1 :         {
      28             :                 /// <summary>
      29             :                 /// Gets the <see cref="IAkkaEventPublisherProxy{TAuthenticationToken}"/>
      30             :                 /// </summary>
      31             :                 protected IAkkaEventPublisherProxy<TAuthenticationToken> EventPublisher { get; private set; }
      32             : 
      33             :                 /// <summary>
      34             :                 /// Instantiates a new instance of <see cref="AkkaSagaRepository{TAuthenticationToken}"/>
      35             :                 /// </summary>
      36           1 :                 public AkkaSagaRepository(IAggregateFactory aggregateFactory, IEventStore<TAuthenticationToken> eventStore, IEventPublisher<TAuthenticationToken> publisher, ICommandPublisher<TAuthenticationToken> commandPublisher, ICorrelationIdHelper correlationIdHelper, IAkkaEventPublisherProxy<TAuthenticationToken> eventPublisher)
      37             :                         : base(aggregateFactory, eventStore, publisher, commandPublisher, correlationIdHelper)
      38             :                 {
      39             :                         EventPublisher = eventPublisher;
      40             :                 }
      41             : 
      42             :                 #region Overrides of Repository<TAuthenticationToken>
      43             : 
      44             :                 /// <summary>
      45             :                 /// Calls <see cref="IAggregateFactory.Create"/> to get a, <typeparamref name="TSaga"/>.
      46             :                 /// </summary>
      47             :                 /// <typeparam name="TSaga">The <see cref="Type"/> of <see cref="ISaga{TAuthenticationToken}"/>.</typeparam>
      48             :                 /// <param name="id">The id of the <typeparamref name="TSaga"/> to create.</param>
      49           1 :                 protected override TSaga CreateSaga<TSaga>(Guid id)
      50             :                 {
      51             :                         var saga = SagaFactory.Create<TSaga>();
      52             : 
      53             :                         return saga;
      54             :                 }
      55             : 
      56             :                 /// <summary>
      57             :                 /// Publish the saved <paramref name="event"/> asynchronously on <see cref="EventPublisher"/>,
      58             :                 /// then calls <see cref="SagaRepository{TAuthenticationToken}.PublishEvent"/>
      59             :                 /// </summary>
      60           1 :                 protected override void PublishEvent(ISagaEvent<TAuthenticationToken> @event)
      61             :                 {
      62             :                         Task.Factory.StartNewSafely(() =>
      63             :                         {
      64             :                                 EventPublisher.Publish(@event);
      65             :                                 base.PublishEvent(@event);
      66             :                         });
      67             :                 }
      68             : 
      69             :                 #endregion
      70             :         }
      71             : }

Generated by: LCOV version 1.12