Skip to content

Commit ef1c8ac

Browse files
committed
Move AggregateId to Events
1 parent 864aaed commit ef1c8ac

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

equinox-fc/Domain/Allocation.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module Events =
3232
interface TypeShape.UnionContract.IUnionContract
3333
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
3434
let [<Literal>] categoryId = "Allocation"
35+
let (|AggregateId|) id = Equinox.AggregateId(categoryId, AllocationId.toString id)
3536

3637
module Folds =
3738

@@ -218,8 +219,7 @@ let sync (updates : Update seq, command : Command) (state : Folds.State) : (bool
218219
type Service internal (resolve, ?maxAttempts) =
219220

220221
let log = Serilog.Log.ForContext<Service>()
221-
let (|AggregateId|) id = Equinox.AggregateId(Events.categoryId, AllocationId.toString id)
222-
let (|Stream|) (AggregateId id) = Equinox.Stream<Events.Event,Folds.State>(log, resolve id, maxAttempts = defaultArg maxAttempts 3)
222+
let (|Stream|) (Events.AggregateId id) = Equinox.Stream<Events.Event,Folds.State>(log, resolve id, maxAttempts = defaultArg maxAttempts 3)
223223

224224
member __.Sync(allocationId,updates,command) : Async<bool*ProcessState> =
225225
let (Stream stream) = allocationId

equinox-fc/Domain/Allocator.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module Events =
1616
interface TypeShape.UnionContract.IUnionContract
1717
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
1818
let [<Literal>] categoryId = "Allocator"
19+
let (|AggregateId|) id = Equinox.AggregateId(categoryId, AllocatorId.toString id)
1920

2021
module Folds =
2122

@@ -40,8 +41,7 @@ let decideComplete allocationId reason : Folds.State -> Events.Event list = func
4041
type Service internal (resolve, ?maxAttempts) =
4142

4243
let log = Serilog.Log.ForContext<Service>()
43-
let (|AggregateId|) id = Equinox.AggregateId(Events.categoryId, AllocatorId.toString id)
44-
let (|Stream|) (AggregateId id) = Equinox.Stream<Events.Event,Folds.State>(log, resolve id, maxAttempts = defaultArg maxAttempts 3)
44+
let (|Stream|) (Events.AggregateId id) = Equinox.Stream<Events.Event,Folds.State>(log, resolve id, maxAttempts = defaultArg maxAttempts 3)
4545

4646
member __.Commence(allocatorId, allocationId, cutoff) : Async<CommenceResult> =
4747
let (Stream stream) = allocatorId

equinox-fc/Domain/Ticket.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Events =
1313
interface TypeShape.UnionContract.IUnionContract
1414
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
1515
let [<Literal>] categoryId = "Ticket"
16+
let (|AggregateId|) id = Equinox.AggregateId(categoryId, TicketId.toString id)
1617

1718
module Folds =
1819

@@ -50,8 +51,7 @@ let decide (allocator : AllocatorId) (command : Command) (state : Folds.State) :
5051
type Service internal (resolve, ?maxAttempts) =
5152

5253
let log = Serilog.Log.ForContext<Service>()
53-
let (|AggregateId|) id = Equinox.AggregateId(Events.categoryId, TicketId.toString id)
54-
let (|Stream|) (AggregateId id) = Equinox.Stream<Events.Event,Folds.State>(log, resolve id, maxAttempts = defaultArg maxAttempts 3)
54+
let (|Stream|) (Events.AggregateId id) = Equinox.Stream<Events.Event,Folds.State>(log, resolve id, maxAttempts = defaultArg maxAttempts 3)
5555

5656
/// Attempts to achieve the intent represented by `command`. High level semantics as per comments on Command (see decide for lowdown)
5757
/// `false` is returned if a competing allocator holds it (or we're attempting to jump straight to Allocated without first Reserving)

equinox-fc/Domain/TicketList.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Events =
1111
interface TypeShape.UnionContract.IUnionContract
1212
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
1313
let [<Literal>] categoryId = "TicketList"
14+
let (|AggregateId|) id = Equinox.AggregateId(categoryId, TicketListId.toString id)
1415

1516
module Folds =
1617

@@ -31,8 +32,7 @@ let interpret (allocatorId : AllocatorId, allocated : TicketId list) (state : Fo
3132
type Service internal (resolve, ?maxAttempts) =
3233

3334
let log = Serilog.Log.ForContext<Service>()
34-
let (|AggregateId|) id = Equinox.AggregateId(Events.categoryId, TicketListId.toString id)
35-
let (|Stream|) (AggregateId id) = Equinox.Stream<Events.Event,Folds.State>(log, resolve id, maxAttempts = defaultArg maxAttempts 3)
35+
let (|Stream|) (Events.AggregateId id) = Equinox.Stream<Events.Event,Folds.State>(log, resolve id, maxAttempts = defaultArg maxAttempts 3)
3636

3737
member __.Sync(pickListId,allocatorId,assignedTickets) : Async<unit> =
3838
let (Stream stream) = pickListId

0 commit comments

Comments
 (0)