diff --git a/samples/Infrastructure/Services.fs b/samples/Infrastructure/Services.fs index fe043a758..4bd84cab6 100644 --- a/samples/Infrastructure/Services.fs +++ b/samples/Infrastructure/Services.fs @@ -24,17 +24,20 @@ type ServiceBuilder(storageConfig, handlerLog) = member __.CreateFavoritesService() = let codec = genCodec() - let fold, initial, snapshot = Domain.Favorites.Folds.fold, Domain.Favorites.Folds.initial, Domain.Favorites.Folds.snapshot + let fold, initial = Domain.Favorites.Folds.fold, Domain.Favorites.Folds.initial + let snapshot = Domain.Favorites.Folds.isOrigin,Domain.Favorites.Folds.compact Backend.Favorites.Service(handlerLog, resolver.Resolve(codec,fold,initial,snapshot)) member __.CreateSaveForLaterService() = let codec = genCodec() - let fold, initial, snapshot = Domain.SavedForLater.Folds.fold, Domain.SavedForLater.Folds.initial, Domain.SavedForLater.Folds.snapshot + let fold, initial = Domain.SavedForLater.Folds.fold, Domain.SavedForLater.Folds.initial + let snapshot = Domain.SavedForLater.Folds.isOrigin,Domain.SavedForLater.Folds.compact Backend.SavedForLater.Service(handlerLog, resolver.Resolve(codec,fold,initial,snapshot), maxSavedItems=50, maxAttempts=3) member __.CreateTodosService() = let codec = genCodec() - let fold, initial, snapshot = TodoBackend.Folds.fold, TodoBackend.Folds.initial, TodoBackend.Folds.snapshot + let fold, initial = TodoBackend.Folds.fold, TodoBackend.Folds.initial + let snapshot = TodoBackend.Folds.isOrigin, TodoBackend.Folds.compact TodoBackend.Service(handlerLog, resolver.Resolve(codec,fold,initial,snapshot)) let register (services : IServiceCollection, storageConfig, handlerLog) = diff --git a/samples/Store/Domain/Cart.fs b/samples/Store/Domain/Cart.fs index 01d8037ec..d53cad63f 100644 --- a/samples/Store/Domain/Cart.fs +++ b/samples/Store/Domain/Cart.fs @@ -41,7 +41,7 @@ module Folds = | Events.ItemWaiveReturnsChanged e -> updateItems (List.map (function i when i.skuId = e.skuId -> { i with returnsWaived = e.waived } | i -> i)) let fold state = Seq.fold evolve state let isOrigin = function Events.Compacted _ -> true | _ -> false - let snapshot = isOrigin, State.toSnapshot >> Events.Compacted + let compact = State.toSnapshot >> Events.Compacted type Context = { time: System.DateTime; requestId : RequestId } type Command = | AddItem of Context * SkuId * quantity: int diff --git a/samples/Store/Domain/Favorites.fs b/samples/Store/Domain/Favorites.fs index 49c043012..b1cad2b3a 100644 --- a/samples/Store/Domain/Favorites.fs +++ b/samples/Store/Domain/Favorites.fs @@ -36,7 +36,7 @@ module Folds = for e in events do evolve s e s.AsState() let isOrigin = function Events.Compacted _ -> true | _ -> false - let snapshot = isOrigin, fun state -> Events.Compacted { net = state } + let compact state = Events.Compacted { net = state } type Command = | Favorite of date : System.DateTimeOffset * skuIds : SkuId list diff --git a/samples/Store/Domain/SavedForLater.fs b/samples/Store/Domain/SavedForLater.fs index 168e682ff..1ef9fd131 100644 --- a/samples/Store/Domain/SavedForLater.fs +++ b/samples/Store/Domain/SavedForLater.fs @@ -61,10 +61,8 @@ module Folds = let proposedEventsWouldExceedLimit maxSavedItems events state = let newState = fold state events Array.length newState > maxSavedItems - let snapshot = - let isOrigin = function Compacted _ -> true | _ -> false - let generate state = Events.Compacted { items = state } - isOrigin, generate + let isOrigin = function Compacted _ -> true | _ -> false + let compact state = Events.Compacted { items = state } module Commands = type Command = diff --git a/samples/Store/Integration/CartIntegration.fs b/samples/Store/Integration/CartIntegration.fs index 22e62fc1d..4bd19f57c 100644 --- a/samples/Store/Integration/CartIntegration.fs +++ b/samples/Store/Integration/CartIntegration.fs @@ -6,7 +6,8 @@ open Swensen.Unquote #nowarn "1182" // From hereon in, we may have some 'unused' privates (the tests) -let fold, initial, snapshot = Domain.Cart.Folds.fold, Domain.Cart.Folds.initial, Domain.Cart.Folds.snapshot +let fold, initial = Domain.Cart.Folds.fold, Domain.Cart.Folds.initial +let snapshot = Domain.Cart.Folds.isOrigin, Domain.Cart.Folds.compact let createMemoryStore () = new VolatileStore () diff --git a/samples/Store/Integration/FavoritesIntegration.fs b/samples/Store/Integration/FavoritesIntegration.fs index 8c744c8f9..018f9e5d2 100644 --- a/samples/Store/Integration/FavoritesIntegration.fs +++ b/samples/Store/Integration/FavoritesIntegration.fs @@ -6,7 +6,8 @@ open Swensen.Unquote #nowarn "1182" // From hereon in, we may have some 'unused' privates (the tests) -let fold, initial, snapshot = Domain.Favorites.Folds.fold, Domain.Favorites.Folds.initial, Domain.Favorites.Folds.snapshot +let fold, initial = Domain.Favorites.Folds.fold, Domain.Favorites.Folds.initial +let snapshot = Domain.Favorites.Folds.isOrigin, Domain.Favorites.Folds.compact let createMemoryStore () = new VolatileStore() diff --git a/samples/TodoBackend/TodosService.fs b/samples/TodoBackend/TodosService.fs index bc67e5cbc..7a1dbc5d2 100644 --- a/samples/TodoBackend/TodosService.fs +++ b/samples/TodoBackend/TodosService.fs @@ -26,7 +26,7 @@ module Folds = | Compacted items -> { s with items = List.ofArray items } let fold state = Seq.fold evolve state let isOrigin = function Events.Cleared | Events.Compacted _ -> true | _ -> false - let snapshot = isOrigin, fun state -> Compacted (Array.ofList state.items) + let compact state = Compacted (Array.ofList state.items) type Command = Add of Todo | Update of Todo | Delete of id: int | Clear diff --git a/tests/Equinox.EventStore.Integration/EventStoreIntegration.fs b/tests/Equinox.EventStore.Integration/EventStoreIntegration.fs index 3abf83506..191ab787e 100644 --- a/tests/Equinox.EventStore.Integration/EventStoreIntegration.fs +++ b/tests/Equinox.EventStore.Integration/EventStoreIntegration.fs @@ -23,7 +23,8 @@ let genCodec<'Union when 'Union :> TypeShape.UnionContract.IUnionContract>() = Equinox.UnionCodec.JsonUtf8.Create<'Union>(serializationSettings) module Cart = - let fold, initial, snapshot = Domain.Cart.Folds.fold, Domain.Cart.Folds.initial, Domain.Cart.Folds.snapshot + let fold, initial = Domain.Cart.Folds.fold, Domain.Cart.Folds.initial + let snapshot = Domain.Cart.Folds.isOrigin, Domain.Cart.Folds.compact let codec = genCodec() let createServiceWithoutOptimization log gateway = Backend.Cart.Service(log, GesResolver(gateway, codec, fold, initial).Resolve)