Documentation Coverage Report
Current view: top level - Azure/Cqrs.Azure.ServiceBus - IAzureBusHelper.cs Hit Total Coverage
Version: 2.2 Artefacts: 11 11 100.0 %
Date: 2017-09-22

          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;
      11             : using cdmdotnet.Logging;
      12             : using Cqrs.Bus;
      13             : using Cqrs.Commands;
      14             : using Cqrs.Events;
      15             : using Cqrs.Messages;
      16             : using Microsoft.ServiceBus.Messaging;
      17             : 
      18             : namespace Cqrs.Azure.ServiceBus
      19             : {
      20             :         /// <summary>
      21             :         /// A helper for Azure Service Bus and Event Hub.
      22             :         /// </summary>
      23             :         /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
      24             :         public interface IAzureBusHelper<TAuthenticationToken>
      25             :         {
      26             :                 /// <summary>
      27             :                 /// Prepares a <see cref="ICommand{TAuthenticationToken}"/> to be sent specifying the framework it is sent via.
      28             :                 /// </summary>
      29             :                 /// <typeparam name="TCommand">The <see cref="Type"/> of<see cref="ICommand{TAuthenticationToken}"/> being sent.</typeparam>
      30             :                 /// <param name="command">The <see cref="ICommand{TAuthenticationToken}"/> to send.</param>
      31             :                 /// <param name="framework">The framework the <paramref name="command"/> is being sent from.</param>
      32           1 :                 void PrepareCommand<TCommand>(TCommand command, string framework)
      33             :                         where TCommand : ICommand<TAuthenticationToken>;
      34             : 
      35             :                 /// <summary>
      36             :                 /// Prepares and validates a <see cref="ICommand{TAuthenticationToken}"/> to be sent specifying the framework it is sent via.
      37             :                 /// </summary>
      38             :                 /// <typeparam name="TCommand">The <see cref="Type"/> of<see cref="ICommand{TAuthenticationToken}"/> being sent.</typeparam>
      39             :                 /// <param name="command">The <see cref="ICommand{TAuthenticationToken}"/> to send.</param>
      40             :                 /// <param name="framework">The framework the <paramref name="command"/> is being sent from.</param>
      41           1 :                 bool PrepareAndValidateCommand<TCommand>(TCommand command, string framework)
      42             :                         where TCommand : ICommand<TAuthenticationToken>;
      43             : 
      44             :                 /// <summary>
      45             :                 /// Deserialises and processes the <paramref name="messageBody"/> received from the network through the provided <paramref name="receiveCommandHandler"/>.
      46             :                 /// </summary>
      47             :                 /// <param name="messageBody">A serialised <see cref="IMessage"/>.</param>
      48             :                 /// <param name="receiveCommandHandler">The handler method that will process the <see cref="ICommand{TAuthenticationToken}"/>.</param>
      49             :                 /// <param name="messageId">The network id of the <see cref="IMessage"/>.</param>
      50             :                 /// <param name="skippedAction">The <see cref="Action"/> to call when the <see cref="ICommand{TAuthenticationToken}"/> is being skipped.</param>
      51             :                 /// <param name="lockRefreshAction">The <see cref="Action"/> to call to refresh the network lock.</param>
      52             :                 /// <returns>The <see cref="ICommand{TAuthenticationToken}"/> that was processed.</returns>
      53           1 :                 ICommand<TAuthenticationToken> ReceiveCommand(string messageBody, Func<ICommand<TAuthenticationToken>, bool?> receiveCommandHandler, string messageId, Action skippedAction = null, Action lockRefreshAction = null);
      54             : 
      55             :                 /// <summary>
      56             :                 /// The default command handler that
      57             :                 /// check if the <see cref="ICommand{TAuthenticationToken}"/> has already been processed by this framework,
      58             :                 /// checks if the <see cref="ICommand{TAuthenticationToken}"/> is required,
      59             :                 /// finds the handler from the provided <paramref name="routeManager"/>.
      60             :                 /// </summary>
      61             :                 /// <param name="command">The <see cref="ICommand{TAuthenticationToken}"/> to process.</param>
      62             :                 /// <param name="routeManager">The <see cref="RouteManager"/> to get the <see cref="ICommandHandler{TAuthenticationToken,TCommand}"/> from.</param>
      63             :                 /// <param name="framework">The current framework.</param>
      64             :                 /// <returns>
      65             :                 /// True indicates the <paramref name="command"/> was successfully handled by a handler.
      66             :                 /// False indicates the <paramref name="command"/> wasn't handled, but didn't throw an error, so by convention, that means it was skipped.
      67             :                 /// Null indicates the command<paramref name="command"/> wasn't handled as it was already handled.
      68             :                 /// </returns>
      69           1 :                 bool? DefaultReceiveCommand(ICommand<TAuthenticationToken> command, RouteManager routeManager, string framework);
      70             : 
      71             :                 /// <summary>
      72             :                 /// Prepares an <see cref="IEvent{TAuthenticationToken}"/> to be sent specifying the framework it is sent via.
      73             :                 /// </summary>
      74             :                 /// <typeparam name="TEvent">The <see cref="Type"/> of<see cref="IEvent{TAuthenticationToken}"/> being sent.</typeparam>
      75             :                 /// <param name="event">The <see cref="IEvent{TAuthenticationToken}"/> to send.</param>
      76             :                 /// <param name="framework">The framework the <paramref name="event"/> is being sent from.</param>
      77           1 :                 void PrepareEvent<TEvent>(TEvent @event, string framework)
      78             :                         where TEvent : IEvent<TAuthenticationToken>;
      79             : 
      80             :                 /// <summary>
      81             :                 /// Prepares and validates an <see cref="IEvent{TAuthenticationToken}"/> to be sent specifying the framework it is sent via.
      82             :                 /// </summary>
      83             :                 /// <typeparam name="TEvent">The <see cref="Type"/> of<see cref="IEvent{TAuthenticationToken}"/> being sent.</typeparam>
      84             :                 /// <param name="event">The <see cref="IEvent{TAuthenticationToken}"/> to send.</param>
      85             :                 /// <param name="framework">The framework the <paramref name="event"/> is being sent from.</param>
      86           1 :                 bool PrepareAndValidateEvent<TEvent>(TEvent @event, string framework)
      87             :                         where TEvent : IEvent<TAuthenticationToken>;
      88             : 
      89             :                 /// <summary>
      90             :                 /// Deserialises and processes the <paramref name="messageBody"/> received from the network through the provided <paramref name="receiveEventHandler"/>.
      91             :                 /// </summary>
      92             :                 /// <param name="messageBody">A serialised <see cref="IMessage"/>.</param>
      93             :                 /// <param name="receiveEventHandler">The handler method that will process the <see cref="IEvent{TAuthenticationToken}"/>.</param>
      94             :                 /// <param name="messageId">The network id of the <see cref="IMessage"/>.</param>
      95             :                 /// <param name="skippedAction">The <see cref="Action"/> to call when the <see cref="IEvent{TAuthenticationToken}"/> is being skipped.</param>
      96             :                 /// <param name="lockRefreshAction">The <see cref="Action"/> to call to refresh the network lock.</param>
      97             :                 /// <returns>The <see cref="IEvent{TAuthenticationToken}"/> that was processed.</returns>
      98           1 :                 IEvent<TAuthenticationToken> ReceiveEvent(string messageBody, Func<IEvent<TAuthenticationToken>, bool?> receiveEventHandler, string messageId, Action skippedAction = null, Action lockRefreshAction = null);
      99             : 
     100             :                 /// <summary>
     101             :                 /// Refreshes the network lock.
     102             :                 /// </summary>
     103           1 :                 void RefreshLock(CancellationTokenSource brokeredMessageRenewCancellationTokenSource, BrokeredMessage message, string type = "message");
     104             : 
     105             :                 /// <summary>
     106             :                 /// The default event handler that
     107             :                 /// check if the <see cref="IEvent{TAuthenticationToken}"/> has already been processed by this framework,
     108             :                 /// checks if the <see cref="IEvent{TAuthenticationToken}"/> is required,
     109             :                 /// finds the handler from the provided <paramref name="routeManager"/>.
     110             :                 /// </summary>
     111             :                 /// <param name="event">The <see cref="IEvent{TAuthenticationToken}"/> to process.</param>
     112             :                 /// <param name="routeManager">The <see cref="RouteManager"/> to get the <see cref="IEventHandler{TAuthenticationToken,TCommand}"/> from.</param>
     113             :                 /// <param name="framework">The current framework.</param>
     114             :                 /// <returns>
     115             :                 /// True indicates the <paramref name="event"/> was successfully handled by a handler.
     116             :                 /// False indicates the <paramref name="event"/> wasn't handled, but didn't throw an error, so by convention, that means it was skipped.
     117             :                 /// Null indicates the <paramref name="event"/> wasn't handled as it was already handled.
     118             :                 /// </returns>
     119           1 :                 bool? DefaultReceiveEvent(IEvent<TAuthenticationToken> @event, RouteManager routeManager, string framework);
     120             : 
     121             :                 /// <summary>
     122             :                 /// Manually registers the provided <paramref name="handler"/> 
     123             :                 /// on the provided <paramref name="routeManger"/>
     124             :                 /// </summary>
     125             :                 /// <typeparam name="TMessage">The <see cref="Type"/> of <see cref="IMessage"/> the <paramref name="handler"/> can handle.</typeparam>
     126           1 :                 void RegisterHandler<TMessage>(ITelemetryHelper telemetryHelper, RouteManager routeManger, Action<TMessage> handler, Type targetedType, bool holdMessageLock = true)
     127             :                         where TMessage : IMessage;
     128             : 
     129             :                 /// <summary>
     130             :                 /// Register an event handler that will listen and respond to all events.
     131             :                 /// </summary>
     132           1 :                 void RegisterGlobalEventHandler<TMessage>(ITelemetryHelper telemetryHelper, RouteManager routeManger, Action<TMessage> handler, bool holdMessageLock = true)
     133             :                         where TMessage : IMessage;
     134             :         }
     135             : }

Generated by: LCOV version 1.10