Skip to content

Commit

Permalink
Cleanup from Cosmos
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Jun 12, 2020
1 parent e6d514f commit 0314a16
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions equinox-fc/Domain.Tests/LocationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ open FSharp.UMX
open Swensen.Unquote
open System

open Fc.Domain
open Fc.Domain.Location

/// Helpers to match `module Cosmos/EventStore` wrapping inside the impl
Expand All @@ -28,7 +29,7 @@ module Location =
let epochs = Epoch.create (Epoch.resolve store) maxAttempts
create (zeroBalance, toBalanceCarriedForward, shouldClose) (series, epochs)

let run (service : Fc.Domain.Location.Service) (IdsAtLeastOne locations, deltas : _[], transactionId) = Async.RunSynchronously <| async {
let run (service : Service) (IdsAtLeastOne locations, deltas : _[], transactionId) = Async.RunSynchronously <| async {
let runId = mkId () // Need to make making state in store unique when replaying or shrinking
let locations = locations |> Array.map (fun x -> % (sprintf "%O/%O" x runId))

Expand Down Expand Up @@ -70,5 +71,5 @@ type EventStore(testOutput) =
let epochLen, idsWindow = max 1 epochLen, 5
let zero, cf, sc = Epoch.zeroBalance, Epoch.toBalanceCarriedForward idsWindow, Epoch.shouldClose epochLen

let service = Fc.Domain.Location.EventStore.create (zero, cf, sc) (context, cache, 50)
let service = Location.EventStore.create (zero, cf, sc) (context, cache, 50)
run service args
2 changes: 1 addition & 1 deletion equinox-fc/Domain/StockProcessManager.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Service(transactions : StockTransaction.Service, locations : Location.Servi

module EventStore =

let create inventoryId (epochLen, idsWindow, maxAttempts) (context, cache) =
let create (context, cache) inventoryId (epochLen, idsWindow, maxAttempts) =
let transactions, locations, inventory =
let transactions = StockTransaction.EventStore.create (context, cache)
let zero, cf, sc = Location.Epoch.zeroBalance, Location.Epoch.toBalanceCarriedForward idsWindow, Location.Epoch.shouldClose epochLen
Expand Down
13 changes: 6 additions & 7 deletions equinox-fc/Web/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,15 @@ type Startup() =
.UseEndpoints(fun endpoints -> endpoints.MapControllers() |> ignore)
|> ignore


let build (args : Args.Arguments) =
let cache = Equinox.Cache(AppName, sizeMb=10)

let create =
let es = args.Source
let connection = es.Connect(Log.Logger, Log.Logger, AppName, Equinox.EventStore.ConnectionStrategy.ClusterSingle Equinox.EventStore.NodePreference.Master)
let context = Equinox.EventStore.Context(connection, Equinox.EventStore.BatchingPolicy(maxBatchSize=500))
Fc.Domain.StockProcessManager.EventStore.create (context, cache)
let inventoryId = InventoryId.parse "FC000"

let es = args.Source
let connection = es.Connect(Log.Logger, Log.Logger, AppName, Equinox.EventStore.ConnectionStrategy.ClusterSingle Equinox.EventStore.NodePreference.Master)
let context = Equinox.EventStore.Context(connection, Equinox.EventStore.BatchingPolicy(maxBatchSize=500))
Fc.Domain.StockProcessManager.EventStore.create inventoryId (1000, 5, 3) (context, cache)
create inventoryId (1000, 5, 3)

let run argv args =
let processManager = build args
Expand Down
1 change: 0 additions & 1 deletion equinox-fc/Web/Web.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<ItemGroup>
<PackageReference Include="Argu" Version="5.4.0" />
<PackageReference Include="Destructurama.FSharp" Version="1.1.1-dev-00033" />
<PackageReference Include="Equinox.EventStore" Version="2.1.0" />
<!-- until FsCodec.SystemTextJson is available -->
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
Expand Down

0 comments on commit 0314a16

Please sign in to comment.