-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ♻️ enhance masstransit messaging registration (#235)
- Loading branch information
1 parent
f5f13fa
commit 75c7fa9
Showing
100 changed files
with
1,415 additions
and
826 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
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
31 changes: 22 additions & 9 deletions
31
src/BuildingBlocks/BuildingBlocks.Abstractions/Events/EventEnvelopeMetadata.cs
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 |
---|---|---|
@@ -1,13 +1,26 @@ | ||
namespace BuildingBlocks.Abstractions.Events; | ||
|
||
public interface IEventEnvelopeMetadata | ||
public record EventEnvelopeMetadata( | ||
Guid MessageId, | ||
Guid CorrelationId, | ||
string MessageType, | ||
string Name, | ||
// Causation ID identifies messages that cause other messages to be published. In simple terms, it's used to see what causes what. The first message in a message conversation typically doesn't have a causation ID. Downstream messages get their causation IDs by copying message IDs from messages, causing downstream messages to be published | ||
Guid? CausationId | ||
) | ||
{ | ||
Guid MessageId { get; init; } | ||
string MessageType { get; init; } | ||
string Name { get; init; } | ||
Guid? CausationId { get; init; } | ||
Guid CorrelationId { get; init; } | ||
DateTime Created { get; init; } | ||
long? CreatedUnixTime { get; init; } | ||
IDictionary<string, object?> Headers { get; init; } | ||
public IDictionary<string, object?> Headers { get; init; } = new Dictionary<string, object?>(); | ||
public DateTime Created { get; init; } = DateTime.Now; | ||
public long? CreatedUnixTime { get; init; } = DateTimeHelper.ToUnixTimeSecond(DateTime.Now); | ||
|
||
internal static class DateTimeHelper | ||
{ | ||
private static readonly DateTime _epoch = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | ||
|
||
public static long ToUnixTimeSecond(DateTime datetime) | ||
{ | ||
var unixTime = (datetime.ToUniversalTime() - _epoch).TotalSeconds; | ||
return (long)unixTime; | ||
} | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
src/BuildingBlocks/BuildingBlocks.Abstractions/Messaging/IBusDirectPublisher.cs
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,26 @@ | ||
using BuildingBlocks.Abstractions.Events; | ||
|
||
namespace BuildingBlocks.Abstractions.Messaging; | ||
|
||
public interface IBusDirectPublisher | ||
{ | ||
Task PublishAsync<TMessage>(IEventEnvelope<TMessage> eventEnvelope, CancellationToken cancellationToken = default) | ||
where TMessage : IMessage; | ||
|
||
Task PublishAsync(IEventEnvelope eventEnvelope, CancellationToken cancellationToken = default); | ||
|
||
public Task PublishAsync<TMessage>( | ||
IEventEnvelope<TMessage> eventEnvelope, | ||
string? exchangeOrTopic = null, | ||
string? queue = null, | ||
CancellationToken cancellationToken = default | ||
) | ||
where TMessage : IMessage; | ||
|
||
public Task PublishAsync( | ||
IEventEnvelope eventEnvelope, | ||
string? exchangeOrTopic = null, | ||
string? queue = null, | ||
CancellationToken cancellationToken = default | ||
); | ||
} |
18 changes: 0 additions & 18 deletions
18
src/BuildingBlocks/BuildingBlocks.Abstractions/Messaging/IBusProducer.cs
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
src/BuildingBlocks/BuildingBlocks.Abstractions/Messaging/IBusPublisher.cs
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,28 @@ | ||
using BuildingBlocks.Abstractions.Events; | ||
|
||
namespace BuildingBlocks.Abstractions.Messaging; | ||
|
||
public interface IBusPublisher | ||
{ | ||
public Task PublishAsync<TMessage>(TMessage message, CancellationToken cancellationToken = default) | ||
where TMessage : IMessage; | ||
|
||
Task PublishAsync<TMessage>(IEventEnvelope<TMessage> eventEnvelope, CancellationToken cancellationToken = default) | ||
where TMessage : IMessage; | ||
|
||
public Task PublishAsync<TMessage>( | ||
TMessage message, | ||
string? exchangeOrTopic = null, | ||
string? queue = null, | ||
CancellationToken cancellationToken = default | ||
) | ||
where TMessage : IMessage; | ||
|
||
public Task PublishAsync<TMessage>( | ||
IEventEnvelope<TMessage> eventEnvelope, | ||
string? exchangeOrTopic = null, | ||
string? queue = null, | ||
CancellationToken cancellationToken = default | ||
) | ||
where TMessage : IMessage; | ||
} |
2 changes: 1 addition & 1 deletion
2
src/BuildingBlocks/BuildingBlocks.Abstractions/Messaging/IExternalEventBus.cs
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
namespace BuildingBlocks.Abstractions.Messaging; | ||
|
||
public interface IExternalEventBus : IBusProducer, IBusConsumer; | ||
public interface IExternalEventBus : IBusPublisher, IBusConsumer; |
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
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
Oops, something went wrong.