From ce94f3dfb85bdc73de5350b78b86c510ab5fa2a1 Mon Sep 17 00:00:00 2001 From: Ruben Bartelink Date: Sat, 7 Dec 2019 03:24:54 +0000 Subject: [PATCH] Move AggregateId to Events --- equinox-fc/Domain/LocationEpoch.fs | 8 ++++---- equinox-fc/Domain/LocationSeries.fs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/equinox-fc/Domain/LocationEpoch.fs b/equinox-fc/Domain/LocationEpoch.fs index 37c46b6d5..83725eb66 100644 --- a/equinox-fc/Domain/LocationEpoch.fs +++ b/equinox-fc/Domain/LocationEpoch.fs @@ -13,6 +13,9 @@ module Events = interface TypeShape.UnionContract.IUnionContract let codec = FsCodec.NewtonsoftJson.Codec.Create() let [] categoryId = "LocationEpoch" + let (|AggregateId|) (locationId, epochId) = + let id = sprintf "%s_%s" (LocationId.toString locationId) (LocationEpochId.toString epochId) + Equinox.AggregateId(categoryId, id) module Folds = @@ -69,10 +72,7 @@ let sync (balanceCarriedForward : Folds.Balance option) (decide : (Folds.Balance type Service internal (resolve, ?maxAttempts) = let log = Serilog.Log.ForContext() - 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(log, resolve id, maxAttempts = defaultArg maxAttempts 2) + let (|Stream|) (Events.AggregateId id) = Equinox.Stream(log, resolve id, maxAttempts = defaultArg maxAttempts 2) member __.Sync<'R>(locationId, epochId, prevEpochBalanceCarriedForward, decide, shouldClose) : Async> = let (Stream stream) = (locationId, epochId) diff --git a/equinox-fc/Domain/LocationSeries.fs b/equinox-fc/Domain/LocationSeries.fs index e75ccb9b4..8beebe800 100644 --- a/equinox-fc/Domain/LocationSeries.fs +++ b/equinox-fc/Domain/LocationSeries.fs @@ -10,6 +10,7 @@ module Events = interface TypeShape.UnionContract.IUnionContract let codec = FsCodec.NewtonsoftJson.Codec.Create() let [] categoryId = "LocationSeries" + let (|AggregateId|) id = Equinox.AggregateId(categoryId, LocationId.toString id) module Folds = @@ -28,8 +29,7 @@ let toActiveEpoch state = type Service internal (resolve, ?maxAttempts) = let log = Serilog.Log.ForContext() - let (|AggregateId|) id = Equinox.AggregateId(Events.categoryId, LocationId.toString id) - let (|Stream|) (AggregateId id) = Equinox.Stream(log, resolve id, maxAttempts = defaultArg maxAttempts 2) + let (|Stream|) (Events.AggregateId id) = Equinox.Stream(log, resolve id, maxAttempts = defaultArg maxAttempts 2) member __.Read(locationId) : Async = let (Stream stream) = locationId