Skip to content

Commit 88a1184

Browse files
committed
- Checkpoint: Decouple Command bus and command dispatcher
1 parent bbc0c09 commit 88a1184

File tree

10 files changed

+337
-188
lines changed

10 files changed

+337
-188
lines changed

src/SourceFlow/Aggregate/IAggregateFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ public interface IAggregateFactory
1010
/// <summary>
1111
/// Creates a new instance of an aggregate root with the specified state.
1212
/// </summary>
13-
/// <typeparam name="TAggregateRoot"></typeparam>
13+
/// <typeparam name="TAggregate">Type Implementation of IAgrregate</typeparam>
1414
/// <param name="state"></param>
1515
/// <returns></returns>
16-
Task<TAggregateRoot> Create<TAggregateRoot>()
17-
where TAggregateRoot : IAggregate;
16+
Task<TAggregate> Create<TAggregate>()
17+
where TAggregate : IAggregate;
1818
}
1919
}

src/SourceFlow/ClassDiagram.cd

Lines changed: 111 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<Lollipop Position="0.2" />
2525
</Class>
2626
<Class Name="SourceFlow.Impl.EventQueue">
27-
<Position X="10.25" Y="3" Width="1.5" />
27+
<Position X="10.25" Y="3.5" Width="1.5" />
2828
<TypeIdentifier>
2929
<HashCode>AABAAAAAAAAAAAACAAAAAAAAAEAAAAAAAAAAAAAAAAA=</HashCode>
3030
<FileName>Impl\EventQueue.cs</FileName>
@@ -33,31 +33,33 @@
3333
</Class>
3434
<Class Name="SourceFlow.Impl.CommandBus">
3535
<Position X="3" Y="3" Width="2" />
36-
<AssociationLine Name="sagas" Type="SourceFlow.Saga.ISaga">
37-
<MemberNameLabel ManuallyPlaced="true" ManuallySized="true">
38-
<Position X="0.17" Y="0.117" Height="0.182" Width="0.646" />
36+
<AssociationLine Name="commandStore" Type="SourceFlow.ICommandStore" FixedFromPoint="true" FixedToPoint="true">
37+
<Path>
38+
<Point X="3" Y="5.25" />
39+
<Point X="2.393" Y="5.25" />
40+
<Point X="2.393" Y="8" />
41+
</Path>
42+
<MemberNameLabel ManuallyPlaced="true">
43+
<Position X="0.066" Y="0.147" />
3944
</MemberNameLabel>
4045
</AssociationLine>
4146
<TypeIdentifier>
42-
<HashCode>AAAAABEAABAEAEACAAAAAAAABAAAAAQAAAAAAAAAAAA=</HashCode>
47+
<HashCode>AAgAAAAAABAAAAACAAAAAAAABEAAAAQAAAAAAAAAAAA=</HashCode>
4348
<FileName>Impl\CommandBus.cs</FileName>
4449
</TypeIdentifier>
4550
<ShowAsAssociation>
4651
<Field Name="commandStore" />
4752
</ShowAsAssociation>
48-
<ShowAsCollectionAssociation>
49-
<Field Name="sagas" />
50-
</ShowAsCollectionAssociation>
5153
<Lollipop Position="0.2" />
5254
</Class>
5355
<Class Name="SourceFlow.Aggregate.Aggregate&lt;TAggregate&gt;">
54-
<Position X="14.75" Y="2.5" Width="1.75" />
56+
<Position X="16.5" Y="3.5" Width="1.75" />
5557
<AssociationLine Name="commandPublisher" Type="SourceFlow.Messaging.Bus.ICommandPublisher" ManuallyRouted="true" FixedFromPoint="true" FixedToPoint="true">
5658
<Path>
57-
<Point X="16.5" Y="2.938" />
58-
<Point X="16.878" Y="2.938" />
59-
<Point X="16.878" Y="0.753" />
60-
<Point X="3.562" Y="0.753" />
59+
<Point X="18.25" Y="3.938" />
60+
<Point X="18.631" Y="3.938" />
61+
<Point X="18.631" Y="0.705" />
62+
<Point X="3.562" Y="0.705" />
6163
<Point X="3.562" Y="1.5" />
6264
</Path>
6365
<MemberNameLabel ManuallyPlaced="true">
@@ -66,10 +68,10 @@
6668
</AssociationLine>
6769
<AssociationLine Name="commandReplayer" Type="SourceFlow.Messaging.Bus.ICommandReplayer" ManuallyRouted="true" FixedFromPoint="true" FixedToPoint="true">
6870
<Path>
69-
<Point X="16.5" Y="3.312" />
70-
<Point X="17.301" Y="3.312" />
71-
<Point X="17.301" Y="0.364" />
72-
<Point X="1.125" Y="0.364" />
71+
<Point X="18.25" Y="4.312" />
72+
<Point X="19.066" Y="4.312" />
73+
<Point X="19.066" Y="0.314" />
74+
<Point X="1.125" Y="0.314" />
7375
<Point X="1.125" Y="1.5" />
7476
</Path>
7577
<MemberNameLabel ManuallyPlaced="true">
@@ -87,15 +89,15 @@
8789
<Lollipop Position="0.2" />
8890
</Class>
8991
<Class Name="SourceFlow.Messaging.Event&lt;TEntity&gt;">
90-
<Position X="10.25" Y="5.5" Width="1.5" />
92+
<Position X="10.25" Y="6.25" Width="1.5" />
9193
<AssociationLine Name="IEvent.Payload" Type="SourceFlow.Aggregate.IEntity" FixedFromPoint="true" FixedToPoint="true">
9294
<Path>
93-
<Point X="10.25" Y="6.25" />
94-
<Point X="9" Y="6.25" />
95+
<Point X="10.25" Y="7" />
96+
<Point X="9" Y="7" />
9597
<Point X="9" Y="5.853" />
9698
</Path>
9799
<MemberNameLabel ManuallyPlaced="true" ManuallySized="true">
98-
<Position X="-1.04" Y="0.554" Height="0.182" Width="1.19" />
100+
<Position X="-1.295" Y="0.86" Height="0.182" Width="1.19" />
99101
</MemberNameLabel>
100102
</AssociationLine>
101103
<TypeIdentifier>
@@ -113,11 +115,11 @@
113115
<Path>
114116
<Point X="6.812" Y="8.94" />
115117
<Point X="6.812" Y="9.315" />
116-
<Point X="9.688" Y="9.315" />
117-
<Point X="9.688" Y="8.853" />
118+
<Point X="9.188" Y="9.315" />
119+
<Point X="9.188" Y="8.603" />
118120
</Path>
119-
<MemberNameLabel ManuallyPlaced="true">
120-
<Position X="0.453" Y="0.241" />
121+
<MemberNameLabel ManuallyPlaced="true" ManuallySized="true">
122+
<Position X="0.191" Y="0.372" Height="0.182" Width="1.091" />
121123
</MemberNameLabel>
122124
</AssociationLine>
123125
<TypeIdentifier>
@@ -173,42 +175,21 @@
173175
</ShowAsAssociation>
174176
<Lollipop Position="0.2" />
175177
</Class>
176-
<Class Name="SourceFlow.Impl.BusSubscriber">
177-
<Position X="0.5" Y="8.25" Width="1.5" />
178-
<AssociationLine Name="commandBus" Type="SourceFlow.Messaging.Bus.ICommandBus" ManuallyRouted="true">
179-
<Path>
180-
<Point X="2" Y="8.898" />
181-
<Point X="2.703" Y="8.898" />
182-
<Point X="2.703" Y="3.156" />
183-
<Point X="2" Y="3.156" />
184-
</Path>
185-
<MemberNameLabel ManuallyPlaced="true" ManuallySized="true">
186-
<Position X="-1.449" Y="-4.769" Height="0.182" Width="1.134" />
187-
</MemberNameLabel>
188-
</AssociationLine>
189-
<TypeIdentifier>
190-
<HashCode>AAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAIAA=</HashCode>
191-
<FileName>Impl\BusSubscriber.cs</FileName>
192-
</TypeIdentifier>
193-
<ShowAsAssociation>
194-
<Field Name="commandBus" />
195-
</ShowAsAssociation>
196-
<Lollipop Position="0.2" />
197-
</Class>
198178
<Class Name="SourceFlow.Impl.AggregateFactory">
199-
<Position X="14.75" Y="4.75" Width="2" />
179+
<Position X="16.5" Y="7" Width="2" />
200180
<TypeIdentifier>
201181
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAABAEAAAAAAAAAAAAA=</HashCode>
202182
<FileName>Impl\AggregateFactory.cs</FileName>
203183
</TypeIdentifier>
204184
<Lollipop Position="0.2" />
205185
</Class>
206186
<Class Name="SourceFlow.Services.Service">
207-
<Position X="17" Y="6" Width="1.75" />
208-
<AssociationLine Name="aggregateFactory" Type="SourceFlow.Aggregate.IAggregateFactory" FixedToPoint="true">
187+
<Position X="19" Y="6.25" Width="1.75" />
188+
<AssociationLine Name="aggregateFactory" Type="SourceFlow.Aggregate.IAggregateFactory" FixedFromPoint="true" FixedToPoint="true">
209189
<Path>
210-
<Point X="18.312" Y="6" />
211-
<Point X="18.312" Y="5.312" />
190+
<Point X="20.25" Y="6.25" />
191+
<Point X="20.25" Y="5.746" />
192+
<Point X="18.25" Y="5.746" />
212193
</Path>
213194
</AssociationLine>
214195
<TypeIdentifier>
@@ -220,8 +201,60 @@
220201
</ShowAsAssociation>
221202
<Lollipop Position="0.2" />
222203
</Class>
204+
<Class Name="SourceFlow.Impl.EventDispatcher">
205+
<Position X="12.25" Y="3.5" Width="1.5" />
206+
<AssociationLine Name="projections" Type="SourceFlow.ViewModel.IProjection" FixedFromPoint="true" FixedToPoint="true">
207+
<Path>
208+
<Point X="13" Y="5.632" />
209+
<Point X="13" Y="5.918" />
210+
<Point X="15.188" Y="5.918" />
211+
<Point X="15.188" Y="5.618" />
212+
</Path>
213+
<MemberNameLabel ManuallyPlaced="true">
214+
<Position X="0.315" Y="0.132" />
215+
</MemberNameLabel>
216+
</AssociationLine>
217+
<AssociationLine Name="aggregates" Type="SourceFlow.Aggregate.IAggregate" FixedFromPoint="true" FixedToPoint="true">
218+
<Path>
219+
<Point X="13.75" Y="4.375" />
220+
<Point X="15.438" Y="4.375" />
221+
<Point X="15.438" Y="4.062" />
222+
</Path>
223+
<MemberNameLabel ManuallyPlaced="true">
224+
<Position X="0.584" Y="0.11" />
225+
</MemberNameLabel>
226+
</AssociationLine>
227+
<TypeIdentifier>
228+
<HashCode>AAgAAAgAAAAAAAgCAAAAAAAAAACAAAAAACAAAAAAAAA=</HashCode>
229+
<FileName>Impl\EventDispatcher.cs</FileName>
230+
</TypeIdentifier>
231+
<ShowAsCollectionAssociation>
232+
<Field Name="projections" />
233+
<Field Name="aggregates" />
234+
</ShowAsCollectionAssociation>
235+
<Lollipop Position="0.1" />
236+
</Class>
237+
<Class Name="SourceFlow.Impl.CommandDispatcher">
238+
<Position X="3" Y="7.5" Width="2" />
239+
<AssociationLine Name="sagas" Type="SourceFlow.Saga.ISaga" ManuallyRouted="true" FixedFromPoint="true" FixedToPoint="true">
240+
<Path>
241+
<Point X="5" Y="8.245" />
242+
<Point X="5.375" Y="8.245" />
243+
<Point X="5.375" Y="4.552" />
244+
<Point X="6" Y="4.552" />
245+
</Path>
246+
</AssociationLine>
247+
<TypeIdentifier>
248+
<HashCode>AAgAAAAAAAAAAEACAEAAAAAAAAABAAAAAAAAAAAAAAA=</HashCode>
249+
<FileName>Impl\CommandDispatcher.cs</FileName>
250+
</TypeIdentifier>
251+
<ShowAsCollectionAssociation>
252+
<Field Name="sagas" />
253+
</ShowAsCollectionAssociation>
254+
<Lollipop Position="0.2" />
255+
</Class>
223256
<Interface Name="SourceFlow.Messaging.Bus.IEventQueue">
224-
<Position X="10" Y="1.5" Width="1.5" />
257+
<Position X="10.25" Y="1.5" Width="1.5" />
225258
<TypeIdentifier>
226259
<HashCode>AABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAA=</HashCode>
227260
<FileName>Messaging\Bus\IEventQueue.cs</FileName>
@@ -242,21 +275,21 @@
242275
</TypeIdentifier>
243276
</Interface>
244277
<Interface Name="SourceFlow.Aggregate.IAggregate" Collapsed="true">
245-
<Position X="14.75" Y="1.5" Width="1.5" />
278+
<Position X="14.5" Y="3.5" Width="1.75" />
246279
<TypeIdentifier>
247280
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
248281
<FileName>Aggregate\IAggregate.cs</FileName>
249282
</TypeIdentifier>
250283
</Interface>
251284
<Interface Name="SourceFlow.ViewModel.IProjection">
252-
<Position X="12.75" Y="4.25" Width="1.75" />
285+
<Position X="14.5" Y="4.75" Width="1.75" />
253286
<TypeIdentifier>
254287
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
255288
<FileName>ViewModel\IProjection.cs</FileName>
256289
</TypeIdentifier>
257290
</Interface>
258291
<Interface Name="SourceFlow.ICommandStore">
259-
<Position X="3.25" Y="6.25" Width="1.5" />
292+
<Position X="0.5" Y="8" Width="2" />
260293
<TypeIdentifier>
261294
<HashCode>ABAAgAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAA=</HashCode>
262295
<FileName>ICommandStore.cs</FileName>
@@ -277,7 +310,7 @@
277310
</TypeIdentifier>
278311
</Interface>
279312
<Interface Name="SourceFlow.ViewModel.IProjectOn&lt;TEvent&gt;">
280-
<Position X="12.75" Y="5.75" Width="1.75" />
313+
<Position X="14.5" Y="6.25" Width="1.75" />
281314
<TypeIdentifier>
282315
<HashCode>AAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
283316
<FileName>ViewModel\IProjection.cs</FileName>
@@ -291,7 +324,7 @@
291324
</TypeIdentifier>
292325
</Interface>
293326
<Interface Name="SourceFlow.Aggregate.ISubscribes&lt;TEvent&gt;">
294-
<Position X="12.75" Y="2.5" Width="1.75" />
327+
<Position X="14.5" Y="2" Width="1.75" />
295328
<TypeIdentifier>
296329
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAA=</HashCode>
297330
<FileName>Aggregate\ISubscribes.cs</FileName>
@@ -300,12 +333,12 @@
300333
<Interface Name="SourceFlow.Messaging.Bus.ICommandBus" Collapsed="true">
301334
<Position X="0.5" Y="3" Width="1.5" />
302335
<TypeIdentifier>
303-
<HashCode>AAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAQAAAQAAAAA=</HashCode>
336+
<HashCode>AAAAAAAAAAAAAAAAAEAAAAAAAEAAAAAAAQAAAAAAAAA=</HashCode>
304337
<FileName>Messaging\Bus\ICommandBus.cs</FileName>
305338
</TypeIdentifier>
306339
</Interface>
307340
<Interface Name="SourceFlow.Messaging.IPayload">
308-
<Position X="8.75" Y="7.75" Width="1.5" />
341+
<Position X="8.25" Y="7.5" Width="1.5" />
309342
<TypeIdentifier>
310343
<HashCode>AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
311344
<FileName>Messaging\IPayload.cs</FileName>
@@ -318,26 +351,40 @@
318351
<FileName>Aggregate\IEntity.cs</FileName>
319352
</TypeIdentifier>
320353
</Interface>
321-
<Interface Name="SourceFlow.Aggregate.IAggregateFactory" Collapsed="true">
322-
<Position X="17" Y="4.75" Width="1.75" />
354+
<Interface Name="SourceFlow.Aggregate.IAggregateFactory">
355+
<Position X="16.5" Y="5.5" Width="1.75" />
323356
<TypeIdentifier>
324357
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAA=</HashCode>
325358
<FileName>Aggregate\IAggregateFactory.cs</FileName>
326359
</TypeIdentifier>
327360
</Interface>
328361
<Interface Name="SourceFlow.IViewProvider">
329-
<Position X="10.75" Y="7.75" Width="1.75" />
362+
<Position X="12.5" Y="7.5" Width="1.75" />
330363
<TypeIdentifier>
331364
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAACAA=</HashCode>
332365
<FileName>IViewProvider.cs</FileName>
333366
</TypeIdentifier>
334367
</Interface>
335368
<Interface Name="SourceFlow.ViewModel.IViewModel">
336-
<Position X="12.75" Y="7.75" Width="1.75" />
369+
<Position X="12.5" Y="6.25" Width="1.75" />
337370
<TypeIdentifier>
338371
<HashCode>AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
339372
<FileName>ViewModel\IViewModel.cs</FileName>
340373
</TypeIdentifier>
341374
</Interface>
375+
<Interface Name="SourceFlow.Messaging.Bus.IEventDispatcher">
376+
<Position X="12.25" Y="2" Width="1.75" />
377+
<TypeIdentifier>
378+
<HashCode>AAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
379+
<FileName>Messaging\Bus\IEventDispatcher.cs</FileName>
380+
</TypeIdentifier>
381+
</Interface>
382+
<Interface Name="SourceFlow.Messaging.Bus.ICommandDispatcher">
383+
<Position X="3" Y="5.75" Width="2" />
384+
<TypeIdentifier>
385+
<HashCode>AAgAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAA=</HashCode>
386+
<FileName>Messaging\Bus\ICommandDispatcher.cs</FileName>
387+
</TypeIdentifier>
388+
</Interface>
342389
<Font Name="Segoe UI" Size="9" />
343390
</ClassDiagram>

src/SourceFlow/Impl/AggregateFactory.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public AggregateFactory(IServiceProvider serviceProvider)
2727
/// <summary>
2828
/// Creates a singleton instance of an aggregate root with the specified state.
2929
/// </summary>
30-
/// <typeparam name="TAggregateRoot"></typeparam>
30+
/// <typeparam name="TAggregate">Type Implementation of IAggregate</typeparam>
3131
/// <returns></returns>
32-
public async Task<TAggregateRoot> Create<TAggregateRoot>()
33-
where TAggregateRoot : IAggregate
32+
public async Task<TAggregate> Create<TAggregate>()
33+
where TAggregate : IAggregate
3434
{
3535
// Resolve the aggregate root from the container
36-
var aggregate = serviceProvider.GetService<IAggregate>();
37-
return await Task.FromResult((TAggregateRoot)aggregate);
36+
var aggregate = serviceProvider.GetService<TAggregate>();
37+
return await Task.FromResult((TAggregate)aggregate);
3838
}
3939
}
4040
}

src/SourceFlow/Impl/BusSubscriber.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)