-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardized the topology for partition key across service bus, event…
… hub, and the SQL transport
- Loading branch information
Showing
18 changed files
with
103 additions
and
127 deletions.
There are no files selected for viewing
19 changes: 9 additions & 10 deletions
19
...iceBusPartitionKeyConventionExtensions.cs → ...ation/PartitionKeyConventionExtensions.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
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,33 @@ | ||
namespace MassTransit.Middleware | ||
{ | ||
using System.Threading.Tasks; | ||
using Transports; | ||
|
||
|
||
public class SetPartitionKeyFilter<TMessage> : | ||
IFilter<SendContext<TMessage>> | ||
where TMessage : class | ||
{ | ||
readonly IMessagePartitionKeyFormatter<TMessage> _routingKeyFormatter; | ||
|
||
public SetPartitionKeyFilter(IMessagePartitionKeyFormatter<TMessage> routingKeyFormatter) | ||
{ | ||
_routingKeyFormatter = routingKeyFormatter; | ||
} | ||
|
||
public Task Send(SendContext<TMessage> context, IPipe<SendContext<TMessage>> next) | ||
{ | ||
var routingKey = _routingKeyFormatter.FormatPartitionKey(context); | ||
|
||
if (context.TryGetPayload(out PartitionKeySendContext routingKeySendContext)) | ||
routingKeySendContext.PartitionKey = routingKey; | ||
|
||
return next.Send(context); | ||
} | ||
|
||
public void Probe(ProbeContext context) | ||
{ | ||
context.CreateFilterScope("setPartitionKey"); | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...titionKeyMessageSendTopologyConvention.cs → ...titionKeyMessageSendTopologyConvention.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
7 changes: 7 additions & 0 deletions
7
src/MassTransit/Topology/Configuration/IPartitionKeySendTopologyConvention.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,7 @@ | ||
namespace MassTransit.Configuration | ||
{ | ||
public interface IPartitionKeySendTopologyConvention : | ||
ISendTopologyConvention | ||
{ | ||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
...titionKeyMessageSendTopologyConvention.cs → ...titionKeyMessageSendTopologyConvention.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
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/MassTransit/Topology/Configuration/SetPartitionKeyMessageSendTopology.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 @@ | ||
namespace MassTransit.Configuration; | ||
|
||
using System; | ||
using Middleware; | ||
using Transports; | ||
|
||
|
||
public class SetPartitionKeyMessageSendTopology<TMessage> : | ||
IMessageSendTopology<TMessage> | ||
where TMessage : class | ||
{ | ||
readonly IFilter<SendContext<TMessage>> _filter; | ||
|
||
public SetPartitionKeyMessageSendTopology(IMessagePartitionKeyFormatter<TMessage> partitionKeyFormatter) | ||
{ | ||
if (partitionKeyFormatter == null) | ||
throw new ArgumentNullException(nameof(partitionKeyFormatter)); | ||
|
||
_filter = new SetPartitionKeyFilter<TMessage>(partitionKeyFormatter); | ||
} | ||
|
||
public void Apply(ITopologyPipeBuilder<SendContext<TMessage>> builder) | ||
{ | ||
builder.AddFilter(_filter); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ransport/DelegatePartitionKeyFormatter.cs → ...ansports/DelegatePartitionKeyFormatter.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,4 +1,4 @@ | ||
namespace MassTransit.AzureServiceBusTransport | ||
namespace MassTransit.Transports | ||
{ | ||
using System; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...ransport/IMessagePartitionKeyFormatter.cs → ...ansports/IMessagePartitionKeyFormatter.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
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,13 @@ | ||
namespace MassTransit.Transports; | ||
|
||
public interface IPartitionKeyFormatter | ||
{ | ||
/// <summary> | ||
/// Format the partition key to be used by the transport, if supported | ||
/// </summary> | ||
/// <typeparam name="T">The message type</typeparam> | ||
/// <param name="context">The message send context</param> | ||
/// <returns>The routing key to specify in the transport</returns> | ||
string FormatPartitionKey<T>(SendContext<T> context) | ||
where T : class; | ||
} |
2 changes: 1 addition & 1 deletion
2
...Transport/MessagePartitionKeyFormatter.cs → ...ransports/MessagePartitionKeyFormatter.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
15 changes: 0 additions & 15 deletions
15
...re/AzureServiceBusTransport/Configuration/Topology/IPartitionKeySendTopologyConvention.cs
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
.../MassTransit.Azure.ServiceBus.Core/AzureServiceBusTransport/EmptyPartitionKeyFormatter.cs
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...orts/MassTransit.Azure.ServiceBus.Core/AzureServiceBusTransport/IPartitionKeyFormatter.cs
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...ransit.Azure.ServiceBus.Core/AzureServiceBusTransport/Middleware/SetPartitionKeyFilter.cs
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
...e.ServiceBus.Core/AzureServiceBusTransport/Topology/SetPartitionKeyMessageSendTopology.cs
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
src/Transports/MassTransit.EventHubIntegration/EventHubSendContext.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