Documentation Coverage Report
Current view: top level - Azure/Cqrs.Azure.ServiceBus - IAzureBusHelper.cs Hit Total Coverage
Version: 4.0 Artefacts: 10 10 100.0 %
Date: 2019-11-24 03:15:41

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

Generated by: LCOV version 1.13