Skip to content

Commit

Permalink
Move AggregateId to Events
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Dec 7, 2019
1 parent 864aaed commit ef1c8ac
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions equinox-fc/Domain/Allocation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module Events =
interface TypeShape.UnionContract.IUnionContract
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
let [<Literal>] categoryId = "Allocation"
let (|AggregateId|) id = Equinox.AggregateId(categoryId, AllocationId.toString id)

module Folds =

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

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

member __.Sync(allocationId,updates,command) : Async<bool*ProcessState> =
let (Stream stream) = allocationId
Expand Down
4 changes: 2 additions & 2 deletions equinox-fc/Domain/Allocator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Events =
interface TypeShape.UnionContract.IUnionContract
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
let [<Literal>] categoryId = "Allocator"
let (|AggregateId|) id = Equinox.AggregateId(categoryId, AllocatorId.toString id)

module Folds =

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

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

member __.Commence(allocatorId, allocationId, cutoff) : Async<CommenceResult> =
let (Stream stream) = allocatorId
Expand Down
4 changes: 2 additions & 2 deletions equinox-fc/Domain/Ticket.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Events =
interface TypeShape.UnionContract.IUnionContract
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
let [<Literal>] categoryId = "Ticket"
let (|AggregateId|) id = Equinox.AggregateId(categoryId, TicketId.toString id)

module Folds =

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

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

/// Attempts to achieve the intent represented by `command`. High level semantics as per comments on Command (see decide for lowdown)
/// `false` is returned if a competing allocator holds it (or we're attempting to jump straight to Allocated without first Reserving)
Expand Down
4 changes: 2 additions & 2 deletions equinox-fc/Domain/TicketList.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Events =
interface TypeShape.UnionContract.IUnionContract
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
let [<Literal>] categoryId = "TicketList"
let (|AggregateId|) id = Equinox.AggregateId(categoryId, TicketListId.toString id)

module Folds =

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

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

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

0 comments on commit ef1c8ac

Please sign in to comment.