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 cdmdotnet.Logging;
11 : using Cqrs.Configuration;
12 : using Cqrs.Messages;
13 :
14 : namespace Cqrs.Bus
15 : {
16 : /// <summary>
17 : /// A helper for command and event buses.
18 : /// </summary>
19 : public interface IBusHelper
20 : {
21 : /// <summary>
22 : /// Checks if a white-list or black-list approach is taken, then checks the <see cref="IConfigurationManager"/> to see if a key exists defining if the event is required or not.
23 : /// If the event is required and it cannot be resolved, an error will be raised.
24 : /// Otherwise the event will be marked as processed.
25 : /// </summary>
26 : /// <param name="messageType">The <see cref="Type"/> of the message being processed.</param>
27 1 : bool IsEventRequired(Type messageType);
28 :
29 : /// <summary>
30 : /// Checks if a white-list or black-list approach is taken, then checks the <see cref="IConfigurationManager"/> to see if a key exists defining if the event is required or not.
31 : /// If the event is required and it cannot be resolved, an error will be raised.
32 : /// Otherwise the event will be marked as processed.
33 : /// </summary>
34 : /// <param name="configurationKey">The configuration key to check.</param>
35 1 : bool IsEventRequired(string configurationKey);
36 :
37 : /// <summary>
38 : /// Checks if the private bus is required to send the message. Note, this does not imply the public bus is not required as well.
39 : /// </summary>
40 : /// <param name="messageType">The <see cref="Type"/> of the message being processed.</param>
41 : /// <returns>Null for unconfigured, True for private bus transmission, false otherwise.</returns>
42 1 : bool? IsPrivateBusRequired(Type messageType);
43 :
44 : /// <summary>
45 : /// Checks if the public bus is required to send the message. Note, this does not imply the public bus is not required as well.
46 : /// </summary>
47 : /// <param name="messageType">The <see cref="Type"/> of the message being processed.</param>
48 : /// <returns>Null for unconfigured, True for private bus transmission, false otherwise.</returns>
49 3 : bool? IsPublicBusRequired(Type messageType);
50 :
51 : /// <summary>
52 : /// Build a message handler that implements telemetry capturing as well as off thread handling.
53 : /// </summary>
54 : Action<TMessage> BuildTelemeteredActionHandler<TMessage, TAuthenticationToken>(ITelemetryHelper telemetryHelper, Action<TMessage> handler, bool holdMessageLock, string source)
55 : where TMessage : IMessage;
56 :
57 : /// <summary>
58 : /// Build a message handler that implements telemetry capturing as well as off thread handling.
59 : /// </summary>
60 : Action<TMessage> BuildActionHandler<TMessage>(Action<TMessage> handler, bool holdMessageLock)
61 : where TMessage : IMessage;
62 :
63 : /// <summary>
64 : /// Indicates if the message was received via the private bus or not. If false, this implies the public was use used.
65 : /// </summary>
66 1 : bool GetWasPrivateBusUsed();
67 :
68 : /// <summary>
69 : /// Set whether the message was received via the private bus or not. If false, this indicates the public was use used.
70 : /// </summary>
71 1 : bool SetWasPrivateBusUsed(bool wasPrivate);
72 : }
73 : }
|