Skip to content

Commit 1db18cf

Browse files
committed
- Checkpoint: Renamed to SagaDispatcher
1 parent 9878f97 commit 1db18cf

File tree

8 files changed

+33
-57
lines changed

8 files changed

+33
-57
lines changed

src/SourceFlow/ClassDiagram.cd

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<Class Name="SourceFlow.Impl.EventQueue">
2727
<Position X="10.25" Y="3.5" Width="1.5" />
2828
<TypeIdentifier>
29-
<HashCode>AABAAAAAAAAAAAACAAAAAAAAAEAAAAAAAAAAAAAAAAA=</HashCode>
29+
<HashCode>AABAAAAAAAAAAAACAAAAAABAAAAAAAAAAAAAAAAAAAA=</HashCode>
3030
<FileName>Impl\EventQueue.cs</FileName>
3131
</TypeIdentifier>
3232
<Lollipop Position="0.2" />
@@ -44,7 +44,7 @@
4444
</MemberNameLabel>
4545
</AssociationLine>
4646
<TypeIdentifier>
47-
<HashCode>AAgAAAAAABAAAAACAAAAAAAABEAAAAQAAAAAAAAAAAA=</HashCode>
47+
<HashCode>AAgAAAAAABAAAAACAAAAAABABAAAAAQAAAAAAAAAAAA=</HashCode>
4848
<FileName>Impl\CommandBus.cs</FileName>
4949
</TypeIdentifier>
5050
<ShowAsAssociation>
@@ -201,67 +201,43 @@
201201
</ShowAsAssociation>
202202
<Lollipop Position="0.2" />
203203
</Class>
204-
<Class Name="SourceFlow.Impl.CommandDispatcher">
204+
<Class Name="SourceFlow.Impl.SagaDispatcher">
205205
<Position X="3" Y="7.5" Width="2" />
206-
<AssociationLine Name="sagas" Type="SourceFlow.Saga.ISaga" ManuallyRouted="true" FixedFromPoint="true" FixedToPoint="true">
207-
<Path>
208-
<Point X="5" Y="8.245" />
209-
<Point X="5.375" Y="8.245" />
210-
<Point X="5.375" Y="4.552" />
211-
<Point X="6" Y="4.552" />
212-
</Path>
213-
</AssociationLine>
214206
<TypeIdentifier>
215207
<HashCode>AAgAAAAAAAAAAEACAEAAAAAAAAABAAAAAAAAAAAAAAA=</HashCode>
216-
<FileName>Impl\CommandDispatcher.cs</FileName>
208+
<FileName>Impl\SagaDispatcher.cs</FileName>
217209
</TypeIdentifier>
218210
<ShowAsCollectionAssociation>
219211
<Field Name="sagas" />
220212
</ShowAsCollectionAssociation>
221213
<Lollipop Position="0.2" />
222214
</Class>
223-
<Class Name="SourceFlow.Impl.ProjectionDispatcher">
224-
<Position X="12.5" Y="6.25" Width="1.75" />
225-
<AssociationLine Name="projections" Type="SourceFlow.ViewModel.IProjection" FixedFromPoint="true" FixedToPoint="true">
226-
<Path>
227-
<Point X="14.25" Y="6.688" />
228-
<Point X="14.625" Y="6.688" />
229-
<Point X="14.625" Y="5.938" />
230-
<Point X="15.5" Y="5.938" />
231-
</Path>
232-
<MemberNameLabel ManuallyPlaced="true">
233-
<Position X="0.138" Y="0.157" />
234-
</MemberNameLabel>
235-
</AssociationLine>
215+
<Class Name="SourceFlow.Impl.AggregateDispatcher">
216+
<Position X="12.5" Y="3.5" Width="1.75" />
236217
<TypeIdentifier>
237-
<HashCode>AAgAAAAAAAAAAAACAAAAAAAAAAAAAAAAACAAAAAAAAA=</HashCode>
238-
<FileName>Impl\ProjectionDispatcher.cs</FileName>
218+
<HashCode>AAgAAAgAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
219+
<FileName>Impl\AggregateDispatcher.cs</FileName>
239220
</TypeIdentifier>
240221
<ShowAsCollectionAssociation>
241-
<Field Name="projections" />
222+
<Field Name="aggregates" />
242223
</ShowAsCollectionAssociation>
243224
<Lollipop Position="0.2" />
244225
</Class>
245-
<Class Name="SourceFlow.Impl.AggregateDispatcher">
246-
<Position X="12.5" Y="3.75" Width="1.75" />
247-
<AssociationLine Name="aggregates" Type="SourceFlow.Aggregate.IAggregate">
248-
<MemberNameLabel ManuallyPlaced="true">
249-
<Position X="0.235" Y="0.06" />
250-
</MemberNameLabel>
251-
</AssociationLine>
226+
<Class Name="SourceFlow.Impl.ProjectionDispatcher">
227+
<Position X="12.5" Y="5.75" Width="1.75" />
252228
<TypeIdentifier>
253-
<HashCode>AAgAAAgAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
254-
<FileName>Impl\AggregateDispatcher.cs</FileName>
229+
<HashCode>AAgAAAAAAAAAAAACAAAAAAAAAAAAAAAAACAAAAAAAAA=</HashCode>
230+
<FileName>Impl\ProjectionDispatcher.cs</FileName>
255231
</TypeIdentifier>
256232
<ShowAsCollectionAssociation>
257-
<Field Name="aggregates" />
233+
<Field Name="projections" />
258234
</ShowAsCollectionAssociation>
259235
<Lollipop Position="0.2" />
260236
</Class>
261237
<Interface Name="SourceFlow.Messaging.Bus.IEventQueue">
262238
<Position X="10.25" Y="1.5" Width="1.5" />
263239
<TypeIdentifier>
264-
<HashCode>AABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAA=</HashCode>
240+
<HashCode>AABAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAA=</HashCode>
265241
<FileName>Messaging\Bus\IEventQueue.cs</FileName>
266242
</TypeIdentifier>
267243
</Interface>
@@ -338,7 +314,7 @@
338314
<Interface Name="SourceFlow.Messaging.Bus.ICommandBus" Collapsed="true">
339315
<Position X="0.5" Y="3" Width="1.5" />
340316
<TypeIdentifier>
341-
<HashCode>AAAAAAAAAAAAAAAAAEAAAAAAAEAAAAAAAQAAAAAAAAA=</HashCode>
317+
<HashCode>AAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAQAAAAAAAAA=</HashCode>
342318
<FileName>Messaging\Bus\ICommandBus.cs</FileName>
343319
</TypeIdentifier>
344320
</Interface>

src/SourceFlow/Impl/CommandBus.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal class CommandBus : ICommandBus
2525
/// <summary>
2626
/// Represents command dispathers that can handle the publishing of commands.
2727
/// </summary>
28-
public event EventHandler<ICommand> Handlers;
28+
public event EventHandler<ICommand> Dispatchers;
2929

3030
/// <summary>
3131
/// Initializes a new instance of the <see cref="CommandBus"/> class.
@@ -60,7 +60,7 @@ private async Task Dispatch<TCommand>(TCommand command) where TCommand : IComman
6060
((IMetadata)command).Metadata.SequenceNo = await commandStore.GetNextSequenceNo(command.Payload.Id);
6161

6262
// 2. Dispatch command to handlers.
63-
Handlers?.Invoke(this, command);
63+
Dispatchers?.Invoke(this, command);
6464

6565
// 3. Log event.
6666
logger?.LogInformation("Action=Command_Dispatched, Command={Command}, Payload={Payload}, SequenceNo={No}, Saga={Saga}",

src/SourceFlow/Impl/EventQueue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal class EventQueue : IEventQueue
2121
/// <summary>
2222
/// Represents event dispathers that can handle the dequeuing of events.
2323
/// </summary>
24-
public event EventHandler<IEvent> Handlers;
24+
public event EventHandler<IEvent> Dispatchers;
2525

2626
/// <summary>
2727
/// Initializes a new instance of the <see cref="EventQueue"/> class with the specified logger.
@@ -45,7 +45,7 @@ public async Task Enqueue<TEvent>(TEvent @event)
4545
if (@event == null)
4646
throw new ArgumentNullException(nameof(@event));
4747

48-
Handlers?.Invoke(this, @event);
48+
Dispatchers?.Invoke(this, @event);
4949

5050
logger?.LogInformation("Action=Event_Enqueue, Event={Event}, Payload={Payload}",
5151
@event.GetType().Name, @event.Payload.GetType().Name);

src/SourceFlow/Impl/CommandDispatcher.cs renamed to src/SourceFlow/Impl/SagaDispatcher.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
namespace SourceFlow.Impl
1111
{
1212
/// <summary>
13-
/// CommandDispatcher is responsible for dispatching commands to registered sagas in an event-driven architecture.
13+
/// This dispatcher is responsible for dispatching commands to registered sagas in an event-driven architecture.
1414
/// </summary>
15-
internal class CommandDispatcher : ICommandDispatcher
15+
internal class SagaDispatcher : ICommandDispatcher
1616
{
1717
/// <summary>
1818
/// Collection of sagas registered with the dispatcher.
@@ -25,10 +25,10 @@ internal class CommandDispatcher : ICommandDispatcher
2525
private readonly ILogger<ICommandDispatcher> logger;
2626

2727
/// <summary>
28-
/// Initializes a new instance of the <see cref="CommandDispatcher"/> class with the specified logger.
28+
/// Initializes a new instance of the <see cref="SagaDispatcher"/> class with the specified logger.
2929
/// </summary>
3030
/// <param name="logger"></param>
31-
public CommandDispatcher(ILogger<ICommandDispatcher> logger)
31+
public SagaDispatcher(ILogger<ICommandDispatcher> logger)
3232
{
3333
this.logger = logger;
3434
sagas = new List<ISaga>();

src/SourceFlow/IocExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void UseSourceFlow(this IServiceCollection services, Action<ISourc
4747
services.AddAsImplementationsOfInterface<ICommandStore>(lifetime: ServiceLifetime.Singleton);
4848
services.AddAsImplementationsOfInterface<IProjection>(lifetime: ServiceLifetime.Singleton);
4949

50-
services.AddSingleton<ICommandDispatcher, CommandDispatcher>(c => new CommandDispatcher(
50+
services.AddSingleton<SagaDispatcher>(c => new SagaDispatcher(
5151
c.GetService<ILogger<ICommandDispatcher>>()));
5252

5353
services.AddSingleton<ICommandBus, CommandBus>(c =>
@@ -56,8 +56,8 @@ public static void UseSourceFlow(this IServiceCollection services, Action<ISourc
5656
c.GetService<ICommandStore>(),
5757
c.GetService<ILogger<ICommandBus>>());
5858

59-
var dispatcher = c.GetService<ICommandDispatcher>();
60-
commandBus.Handlers += dispatcher.Dispatch;
59+
var dispatcher = c.GetService<SagaDispatcher>();
60+
commandBus.Dispatchers += dispatcher.Dispatch;
6161

6262
return commandBus;
6363
});
@@ -78,10 +78,10 @@ public static void UseSourceFlow(this IServiceCollection services, Action<ISourc
7878
c.GetService<ILogger<IEventQueue>>());
7979
// need to register event handlers for the projection before aggregates
8080
var projectionDispatcher = c.GetService<ProjectionDispatcher>();
81-
queue.Handlers += projectionDispatcher.Dispatch;
81+
queue.Dispatchers += projectionDispatcher.Dispatch;
8282
// need to register event handlers for the aggregates after projections
8383
var aggregateDispatcher = c.GetService<AggregateDispatcher>();
84-
queue.Handlers += aggregateDispatcher.Dispatch;
84+
queue.Dispatchers += aggregateDispatcher.Dispatch;
8585

8686
return queue;
8787
});

src/SourceFlow/Messaging/Bus/ICommandBus.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ Task Publish<TCommand>(TCommand command)
2828
/// <summary>
2929
/// Represents command dispathers that can handle the publishing of commands.
3030
/// </summary>
31-
event EventHandler<ICommand> Handlers;
31+
event EventHandler<ICommand> Dispatchers;
3232
}
3333
}

src/SourceFlow/Messaging/Bus/IEventQueue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ namespace SourceFlow.Messaging.Bus
66
public interface IEventQueue
77
{
88
/// <summary>
9-
/// Handlers that are invoked to dispatch an event that is dequeued from the event queue.
9+
/// Dispatchers that are invoked to publish an event that is dequeued from the event queue.
1010
/// </summary>
11-
event EventHandler<IEvent> Handlers;
11+
event EventHandler<IEvent> Dispatchers;
1212

1313
/// <summary>
1414
/// Enqueues an event in order to publish to subcribers.

tests/SourceFlow.Core.Tests/SampleSagaTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
// public Task Handle<TEvent>(TEvent @event) where TEvent : ICommand
3636
// {
3737
// // Example: just call all handlers for the event type
38-
// foreach (var handler in Handlers)
38+
// foreach (var handler in Dispatchers)
3939
// {
4040
// if (handler.EventType == typeof(TEvent))
4141
// ((IHandles<TEvent>)handler.Handler).Handle(@event);

0 commit comments

Comments
 (0)