-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start to abstract message brokers (#1746)
* rename IRabbitMqAdapter -> IMessageBroker * rename RabbitMqAdapter -> RabbitMQBroker and fix namespace * add MessageBrokerType and MessageBrokerFactory
- Loading branch information
Showing
32 changed files
with
169 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- Start to refactor `RabbitMqAdapter` logic into generic interface | ||
- Rename IRabbitMqAdapter -> IMessageBroker | ||
- Move into `Smi.Common.Messaging` namespace | ||
- Add `MessageBrokerType` and `MessageBrokerFactory` | ||
- Create ConnectionFactory directly in `RabbitMQBroker` | ||
- Tidy unused variables and naming |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Smi.Common.Options; | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Smi.Common.Messaging; | ||
|
||
public static class MessageBrokerFactory | ||
{ | ||
[ExcludeFromCodeCoverage] // NOTE(rkm 2024-02-08) This can be removed after we use the class | ||
public static IMessageBroker Create(GlobalOptions globals, string connectionIdentifier) | ||
{ | ||
switch (globals.MessageBrokerType) | ||
{ | ||
case MessageBrokerType.RabbitMQ: | ||
{ | ||
if (globals.RabbitOptions == null) | ||
throw new ArgumentNullException(nameof(globals), $"{nameof(globals.RabbitOptions)} must not be null"); | ||
|
||
return new RabbitMQBroker(globals.RabbitOptions, connectionIdentifier); | ||
} | ||
case MessageBrokerType.None: | ||
throw new ArgumentOutOfRangeException(nameof(globals.MessageBrokerType), $"A valid {nameof(MessageBrokerType)} must be chosen"); | ||
default: | ||
throw new NotImplementedException($"No case for {globals.MessageBrokerType}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Smi.Common.Messaging; | ||
|
||
public enum MessageBrokerType | ||
{ | ||
/// <summary> | ||
/// Unused placeholder value | ||
/// </summary> | ||
None = 0, | ||
|
||
RabbitMQ, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.