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 abd36be commit ce94f3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions equinox-fc/Domain/LocationEpoch.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module Events =
interface TypeShape.UnionContract.IUnionContract
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
let [<Literal>] categoryId = "LocationEpoch"
let (|AggregateId|) (locationId, epochId) =
let id = sprintf "%s_%s" (LocationId.toString locationId) (LocationEpochId.toString epochId)
Equinox.AggregateId(categoryId, id)

module Folds =

Expand Down Expand Up @@ -69,10 +72,7 @@ let sync (balanceCarriedForward : Folds.Balance option) (decide : (Folds.Balance
type Service internal (resolve, ?maxAttempts) =

let log = Serilog.Log.ForContext<Service>()
let (|AggregateId|) (locationId, epochId) =
let id = sprintf "%s_%s" (LocationId.toString locationId) (LocationEpochId.toString epochId)
Equinox.AggregateId(Events.categoryId, id)
let (|Stream|) (AggregateId id) = Equinox.Stream<Events.Event,Folds.State>(log, resolve id, maxAttempts = defaultArg maxAttempts 2)
let (|Stream|) (Events.AggregateId id) = Equinox.Stream<Events.Event,Folds.State>(log, resolve id, maxAttempts = defaultArg maxAttempts 2)

member __.Sync<'R>(locationId, epochId, prevEpochBalanceCarriedForward, decide, shouldClose) : Async<Result<'R>> =
let (Stream stream) = (locationId, epochId)
Expand Down
4 changes: 2 additions & 2 deletions equinox-fc/Domain/LocationSeries.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Events =
interface TypeShape.UnionContract.IUnionContract
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
let [<Literal>] categoryId = "LocationSeries"
let (|AggregateId|) id = Equinox.AggregateId(categoryId, LocationId.toString id)

module Folds =

Expand All @@ -28,8 +29,7 @@ let toActiveEpoch state =
type Service internal (resolve, ?maxAttempts) =

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

member __.Read(locationId) : Async<LocationEpochId option> =
let (Stream stream) = locationId
Expand Down

0 comments on commit ce94f3d

Please sign in to comment.