From bbc55488d634bd75d6b7cfa7fff2f2622a946ec0 Mon Sep 17 00:00:00 2001 From: Ruben Bartelink Date: Fri, 4 Mar 2022 16:18:49 +0000 Subject: [PATCH] Remove usage of __ --- CHANGELOG.md | 4 +- samples/Infrastructure/Services.fs | 6 +-- samples/Store/Domain/Cart.fs | 32 ++++++------ samples/Store/Domain/ContactPreferences.fs | 4 +- samples/Store/Domain/Favorites.fs | 8 +-- samples/Store/Domain/InventoryItem.fs | 4 +- samples/Store/Domain/SavedForLater.fs | 12 ++--- samples/Store/Integration/Infrastructure.fs | 4 +- samples/Store/Integration/LogIntegration.fs | 2 +- samples/TodoBackend/Todo.fs | 6 +-- samples/Tutorial/Cosmos.fsx | 6 +-- samples/Tutorial/Counter.fsx | 6 +-- samples/Tutorial/Todo.fsx | 6 +-- .../Web/Controllers/FavoritesController.fs | 4 +- samples/Web/Controllers/SavesController.fs | 8 +-- samples/Web/Controllers/TodosController.fs | 24 ++++----- src/Equinox.Core/AsyncBatchingGate.fs | 10 ++-- src/Equinox.Core/AsyncCacheCell.fs | 6 +-- src/Equinox.Core/Cache.fs | 12 ++--- src/Equinox.Core/Types.fs | 6 +-- src/Equinox.EventStore/EventStore.fs | 4 +- .../CosmosFixturesInfrastructure.fs | 23 ++++----- .../Infrastructure.fs | 12 ++--- .../Infrastructure.fs | 4 +- tools/Equinox.Tool/Program.fs | 50 +++++++++---------- tools/Equinox.Tool/TodoClient.fs | 8 +-- .../LoadTestRunner.fs | 22 ++++---- 27 files changed, 146 insertions(+), 147 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5e68fea3..33646993d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,12 +10,12 @@ The `Unreleased` section name is replaced by the expected version of next releas ### Added -- `Equinox`: `Decider.Transact(interpret : 'state -> Async<'event list>)` [#308](https://github.com/jet/equinox/pull/308) +- `Equinox`: `Decider.Transact(interpret : 'state -> Async<'event list>)` [#314](https://github.com/jet/equinox/pull/314) ### Changed - `eqx`/`Equinox.Tool`: Flip `-P` option to opt _in_ to pretty printing [#313](https://github.com/jet/equinox/pull/313) -- `Equinox`: rename `Decider.TransactAsync` to `Transact` [#308](https://github.com/jet/equinox/pull/308) +- `Equinox`: rename `Decider.TransactAsync` to `Transact` [#314](https://github.com/jet/equinox/pull/314) - `CosmosStore`: Require `Microsoft.Azure.Cosmos` v `3.0.25` [#310](https://github.com/jet/equinox/pull/310) - `CosmosStore`: Switch to natively using `JsonElement` event bodies [#305](https://github.com/jet/equinox/pull/305) :pray: [@ylibrach](https://github.com/ylibrach) - `CosmosStore`: Switch to natively using `System.Text.Json` for serialization of all `Microsoft.Azure.Cosmos` round-trips [#305](https://github.com/jet/equinox/pull/305) :pray: [@ylibrach](https://github.com/ylibrach) diff --git a/samples/Infrastructure/Services.fs b/samples/Infrastructure/Services.fs index 8f104f840..550dd9338 100644 --- a/samples/Infrastructure/Services.fs +++ b/samples/Infrastructure/Services.fs @@ -27,17 +27,17 @@ type StreamResolver(storage) = type ServiceBuilder(storageConfig, handlerLog) = let cat = StreamResolver(storageConfig) - member __.CreateFavoritesService() = + member _.CreateFavoritesService() = let fold, initial = Favorites.Fold.fold, Favorites.Fold.initial let snapshot = Favorites.Fold.isOrigin,Favorites.Fold.snapshot Favorites.create handlerLog (cat.Resolve(Favorites.Events.codec,fold,initial,snapshot)) - member __.CreateSaveForLaterService() = + member _.CreateSaveForLaterService() = let fold, initial = SavedForLater.Fold.fold, SavedForLater.Fold.initial let snapshot = SavedForLater.Fold.isOrigin,SavedForLater.Fold.compact SavedForLater.create 50 handlerLog (cat.Resolve(SavedForLater.Events.codec,fold,initial,snapshot)) - member __.CreateTodosService() = + member _.CreateTodosService() = let fold, initial = TodoBackend.Fold.fold, TodoBackend.Fold.initial let snapshot = TodoBackend.Fold.isOrigin, TodoBackend.Fold.snapshot TodoBackend.create handlerLog (cat.Resolve(TodoBackend.Events.codec,fold,initial,snapshot)) diff --git a/samples/Store/Domain/Cart.fs b/samples/Store/Domain/Cart.fs index 71fde7815..4fc7da256 100644 --- a/samples/Store/Domain/Cart.fs +++ b/samples/Store/Domain/Cart.fs @@ -109,20 +109,20 @@ type Accumulator<'event, 'state>(fold : 'state -> 'event seq -> 'state, originSt accumulated |> fold originState /// Invoke a decision function, gathering the events (if any) that it decides are necessary into the `Accumulated` sequence - member _.Transact(interpret : 'state -> 'event list) : unit = - interpret __.State |> accumulated.AddRange + member x.Transact(interpret : 'state -> 'event list) : unit = + interpret x.State |> accumulated.AddRange /// Invoke an Async decision function, gathering the events (if any) that it decides are necessary into the `Accumulated` sequence - member _.Transact(interpret : 'state -> Async<'event list>) : Async = async { - let! events = interpret __.State + member x.Transact(interpret : 'state -> Async<'event list>) : Async = async { + let! events = interpret x.State accumulated.AddRange events } /// Invoke a decision function, while also propagating a result yielded as the fst of an (result, events) pair - member _.Transact(decide : 'state -> 'result * 'event list) : 'result = - let result, newEvents = decide __.State + member x.Transact(decide : 'state -> 'result * 'event list) : 'result = + let result, newEvents = decide x.State accumulated.AddRange newEvents result /// Invoke a decision function, while also propagating a result yielded as the fst of an (result, events) pair - member _.Transact(decide : 'state -> Async<'result * 'event list>) : Async<'result> = async { - let! result, newEvents = decide __.State + member x.Transact(decide : 'state -> Async<'result * 'event list>) : Async<'result> = async { + let! result, newEvents = decide x.State accumulated.AddRange newEvents return result } #else @@ -136,7 +136,7 @@ let interpretMany fold interpreters (state : 'state) : 'state * 'event list = type Service internal (resolve : CartId * Equinox.ResolveOption option -> Equinox.Decider) = - member __.Run(cartId, optimistic, commands : Command seq, ?prepare) : Async = + member _.Run(cartId, optimistic, commands : Command seq, ?prepare) : Async = let decider = resolve (cartId,if optimistic then Some Equinox.AllowStale else None) decider.Transact(fun state -> async { match prepare with None -> () | Some prep -> do! prep @@ -144,21 +144,21 @@ type Service internal (resolve : CartId * Equinox.ResolveOption option -> Equino let acc = Accumulator(Fold.fold, state) for cmd in commands do acc.Transact(interpret cmd) - return acc.State, acc.Accumulated } + return acc.State, acc.Accumulated }) #else return interpretMany Fold.fold (Seq.map interpret commands) state }) #endif - member __.ExecuteManyAsync(cartId, optimistic, commands : Command seq, ?prepare) : Async = - __.Run(cartId, optimistic, commands, ?prepare=prepare) |> Async.Ignore + member x.ExecuteManyAsync(cartId, optimistic, commands : Command seq, ?prepare) : Async = + x.Run(cartId, optimistic, commands, ?prepare=prepare) |> Async.Ignore - member __.Execute(cartId, command) = - __.ExecuteManyAsync(cartId, false, [command]) + member x.Execute(cartId, command) = + x.ExecuteManyAsync(cartId, false, [command]) - member __.Read cartId = + member _.Read cartId = let decider = resolve (cartId,None) decider.Query id - member __.ReadStale cartId = + member _.ReadStale cartId = let decider = resolve (cartId,Some Equinox.ResolveOption.AllowStale) decider.Query id diff --git a/samples/Store/Domain/ContactPreferences.fs b/samples/Store/Domain/ContactPreferences.fs index 0242ac78c..cd5baf646 100644 --- a/samples/Store/Domain/ContactPreferences.fs +++ b/samples/Store/Domain/ContactPreferences.fs @@ -45,10 +45,10 @@ type Service internal (resolve : Id -> Equinox.Decider let command = let (Id email) = email in Update { email = email; preferences = value } decider.Transact(interpret command) - member __.Update(email, value) = + member _.Update(email, value) = update email value - member __.Read(email) = + member _.Read(email) = let decider = resolve email decider.Query id diff --git a/samples/Store/Domain/Favorites.fs b/samples/Store/Domain/Favorites.fs index 6f61673a8..7d4e61eab 100644 --- a/samples/Store/Domain/Favorites.fs +++ b/samples/Store/Domain/Favorites.fs @@ -26,10 +26,10 @@ module Fold = let favorite (e : Events.Favorited) = dict.[e.skuId] <- e let favoriteAll (xs: Events.Favorited seq) = for x in xs do favorite x do favoriteAll input - member __.ReplaceAllWith xs = dict.Clear(); favoriteAll xs - member __.Favorite(e : Events.Favorited) = favorite e - member __.Unfavorite id = dict.Remove id |> ignore - member __.AsState() = Seq.toArray dict.Values + member _.ReplaceAllWith xs = dict.Clear(); favoriteAll xs + member _.Favorite(e : Events.Favorited) = favorite e + member _.Unfavorite id = dict.Remove id |> ignore + member _.AsState() = Seq.toArray dict.Values let initial : State = [||] let private evolve (s: InternalState) = function diff --git a/samples/Store/Domain/InventoryItem.fs b/samples/Store/Domain/InventoryItem.fs index d9e3c8c31..3b6db0cca 100644 --- a/samples/Store/Domain/InventoryItem.fs +++ b/samples/Store/Domain/InventoryItem.fs @@ -58,11 +58,11 @@ let interpret command (state : Fold.State) = type Service internal (resolve : InventoryItemId -> Equinox.Decider) = - member __.Execute(itemId, command) = + member _.Execute(itemId, command) = let decider = resolve itemId decider.Transact(interpret command) - member __.Read(itemId) = + member _.Read(itemId) = let decider = resolve itemId decider.Query id diff --git a/samples/Store/Domain/SavedForLater.fs b/samples/Store/Domain/SavedForLater.fs index 338f85db9..ce1d34764 100644 --- a/samples/Store/Domain/SavedForLater.fs +++ b/samples/Store/Domain/SavedForLater.fs @@ -38,16 +38,16 @@ module Fold = let index = Dictionary<_,_>() do for i in externalState do index.[i.skuId] <- i - member __.Replace (skus : seq) = + member _.Replace (skus : seq) = index.Clear() ; for s in skus do index.[s.skuId] <- s - member __.Append(skus : seq) = + member _.Append(skus : seq) = for sku in skus do let ok,found = index.TryGetValue sku.skuId if not ok || found |> isSupersededAt sku.dateSaved then index.[sku.skuId] <- sku - member __.Remove (skus : seq) = + member _.Remove (skus : seq) = for sku in skus do index.Remove sku |> ignore - member __.ToExernalState () = + member _.ToExernalState () = index.Values |> Seq.sortBy (fun s -> -s.dateSaved.Ticks, s.skuId) |> Seq.toArray type State = Item [] @@ -77,7 +77,7 @@ type private Index(state : Events.Item seq) = let index = Dictionary<_,_>() do for i in state do do index.[i.skuId] <- i - member __.DoesNotAlreadyContainSameOrMoreRecent effectiveDate sku = + member _.DoesNotAlreadyContainSameOrMoreRecent effectiveDate sku = match index.TryGetValue sku with | true,item when item.dateSaved >= effectiveDate -> false | _ -> true @@ -125,7 +125,7 @@ type Service internal (resolve : ClientId -> Equinox.Decider = read clientId diff --git a/samples/Store/Integration/Infrastructure.fs b/samples/Store/Integration/Infrastructure.fs index a21e71044..5fccd0455 100644 --- a/samples/Store/Integration/Infrastructure.fs +++ b/samples/Store/Integration/Infrastructure.fs @@ -32,7 +32,7 @@ type TestOutputAdapter(testOutput : Xunit.Abstractions.ITestOutputHelper) = use writer = new System.IO.StringWriter() formatter.Format(logEvent, writer) writer |> string |> testOutput.WriteLine - interface Serilog.Core.ILogEventSink with member __.Emit logEvent = writeSerilogEvent logEvent + interface Serilog.Core.ILogEventSink with member _.Emit logEvent = writeSerilogEvent logEvent [] module SerilogHelpers = @@ -41,4 +41,4 @@ module SerilogHelpers = LoggerConfiguration() .WriteTo.Sink(sink) .WriteTo.Seq("http://localhost:5341") - .CreateLogger() \ No newline at end of file + .CreateLogger() diff --git a/samples/Store/Integration/LogIntegration.fs b/samples/Store/Integration/LogIntegration.fs index 0d49ba769..0f58a27f8 100644 --- a/samples/Store/Integration/LogIntegration.fs +++ b/samples/Store/Integration/LogIntegration.fs @@ -89,7 +89,7 @@ type SerilogMetricsExtractor(emit : string -> unit) = emitEvent logEvent | GenericMessage () as logEvent -> emitEvent logEvent - interface Serilog.Core.ILogEventSink with member __.Emit logEvent = handleLogEvent logEvent + interface Serilog.Core.ILogEventSink with member _.Emit logEvent = handleLogEvent logEvent let createLoggerWithMetricsExtraction emit = let capture = SerilogMetricsExtractor emit diff --git a/samples/TodoBackend/Todo.fs b/samples/TodoBackend/Todo.fs index f8fc67ab1..2180bc307 100644 --- a/samples/TodoBackend/Todo.fs +++ b/samples/TodoBackend/Todo.fs @@ -63,13 +63,13 @@ type Service internal (resolve : ClientId -> Equinox.Decider = + member _.List(clientId) : Async = query clientId (fun s -> s.items |> Seq.ofList) - member __.TryGet(clientId, id) = + member _.TryGet(clientId, id) = query clientId (fun x -> x.items |> List.tryFind (fun x -> x.id = id)) - member __.Execute(clientId, command) : Async = + member _.Execute(clientId, command) : Async = execute clientId command member __.Create(clientId, template: Events.Todo) : Async = async { diff --git a/samples/Tutorial/Cosmos.fsx b/samples/Tutorial/Cosmos.fsx index eef02debf..1c471df21 100644 --- a/samples/Tutorial/Cosmos.fsx +++ b/samples/Tutorial/Cosmos.fsx @@ -72,13 +72,13 @@ module Favorites = type Service internal (resolve : string -> Equinox.Decider) = - member __.Favorite(clientId, sku) = + member _.Favorite(clientId, sku) = let decider = resolve clientId decider.Transact(interpret (Add sku)) - member __.Unfavorite(clientId, skus) = + member _.Unfavorite(clientId, skus) = let decider = resolve clientId decider.Transact(interpret (Remove skus)) - member __.List clientId: Async = + member _.List clientId: Async = let decider = resolve clientId decider.Query id diff --git a/samples/Tutorial/Counter.fsx b/samples/Tutorial/Counter.fsx index 26feaf321..4ef458eba 100644 --- a/samples/Tutorial/Counter.fsx +++ b/samples/Tutorial/Counter.fsx @@ -65,14 +65,14 @@ let decide command (State state) = type Service internal (resolve : string -> Equinox.Decider) = - member __.Execute(instanceId, command) : Async = + member _.Execute(instanceId, command) : Async = let decider = resolve instanceId decider.Transact(decide command) - member __.Reset(instanceId, value) : Async = + member _.Reset(instanceId, value) : Async = __.Execute(instanceId, Clear value) - member __.Read instanceId : Async = + member _.Read instanceId : Async = let decider = resolve instanceId decider.Query(fun (State value) -> value) diff --git a/samples/Tutorial/Todo.fsx b/samples/Tutorial/Todo.fsx index 61664017f..d61cf59c5 100644 --- a/samples/Tutorial/Todo.fsx +++ b/samples/Tutorial/Todo.fsx @@ -81,11 +81,11 @@ type Service internal (resolve : string -> Equinox.Decider) = let decider = resolve clientId decider.Query projection - member __.List clientId : Async = + member _.List clientId : Async = query clientId (fun s -> s.items |> Seq.ofList) - member __.TryGet(clientId, id) = + member _.TryGet(clientId, id) = query clientId (fun x -> x.items |> List.tryFind (fun x -> x.id = id)) - member __.Execute(clientId, command) : Async = + member _.Execute(clientId, command) : Async = execute clientId command member __.Create(clientId, template: Todo) : Async = async { let! state' = handle clientId (Add template) diff --git a/samples/Web/Controllers/FavoritesController.fs b/samples/Web/Controllers/FavoritesController.fs index d073902ca..3cc4c8303 100644 --- a/samples/Web/Controllers/FavoritesController.fs +++ b/samples/Web/Controllers/FavoritesController.fs @@ -9,14 +9,14 @@ type FavoritesController(service : Favorites.Service) = inherit ControllerBase() [] - member __.Get + member _.Get ( []clientId : ClientId) = async { let! res = service.List(clientId) return ActionResult<_> res } [] - member __.Favorite + member _.Favorite ( []clientId : ClientId, []skuIds : SkuId[]) = async { return! service.Favorite(clientId,List.ofArray skuIds) diff --git a/samples/Web/Controllers/SavesController.fs b/samples/Web/Controllers/SavesController.fs index f1fb3df3a..402679c8c 100644 --- a/samples/Web/Controllers/SavesController.fs +++ b/samples/Web/Controllers/SavesController.fs @@ -11,7 +11,7 @@ type SavesController(service : SavedForLater.Service) = inherit ControllerBase() [] - member __.Get + member _.Get ( []clientId : ClientId) = async { let! res = service.List(clientId) return ActionResult<_> res @@ -19,15 +19,15 @@ type SavesController(service : SavedForLater.Service) = // Returns 400 if item limit exceeded [] - member __.Save + member x.Save ( []clientId : ClientId, []skuIds : SkuId[]) : Async = async { let! ok = service.Save(clientId, List.ofArray skuIds) - if ok then return __.NoContent() :> _ else return __.BadRequest("Exceeded maximum number of items in Saved list; please validate before requesting Save.") :> _ + if ok then return x.NoContent() :> _ else return x.BadRequest("Exceeded maximum number of items in Saved list; please validate before requesting Save.") :> _ } [] - member __.Remove + member _.Remove ( []clientId : ClientId, []skuIds : SkuId[]) : Async = async { let resolveSkus _hasSavedSku = async { return skuIds } diff --git a/samples/Web/Controllers/TodosController.fs b/samples/Web/Controllers/TodosController.fs index 46f9818bf..48b1424c8 100644 --- a/samples/Web/Controllers/TodosController.fs +++ b/samples/Web/Controllers/TodosController.fs @@ -25,38 +25,38 @@ type TodosController(service: Service) = let toModel (value : TodoView) : Events.Todo = { id = value.id; order = value.order; title = value.title; completed = value.completed } - member private __.WithUri(x : Events.Todo) : TodoView = - let url = __.Url.RouteUrl("GetTodo", { id=x.id }, __.Request.Scheme) // Supplying scheme is secret sauce for making it absolute as required by client + member private this.WithUri(x : Events.Todo) : TodoView = + let url = this.Url.RouteUrl("GetTodo", { id=x.id }, this.Request.Scheme) // Supplying scheme is secret sauce for making it absolute as required by client { id = x.id; url = url; order = x.order; title = x.title; completed = x.completed } [] - member __.Get([]clientId : ClientId) = async { + member this.Get([]clientId : ClientId) = async { let! xs = service.List(clientId) - return seq { for x in xs -> __.WithUri(x) } + return seq { for x in xs -> this.WithUri(x) } } [] - member __.Get([]clientId : ClientId, id) : Async = async { + member this.Get([]clientId : ClientId, id) : Async = async { let! x = service.TryGet(clientId, id) - return match x with None -> __.NotFound() :> _ | Some x -> ObjectResult(__.WithUri x) :> _ + return match x with None -> this.NotFound() :> _ | Some x -> ObjectResult(this.WithUri x) :> _ } [] - member __.Post([]clientId : ClientId, []value : TodoView) : Async = async { + member this.Post([]clientId : ClientId, []value : TodoView) : Async = async { let! created = service.Create(clientId, toModel value) - return __.WithUri created + return this.WithUri created } [] - member __.Patch([]clientId : ClientId, id, []value : TodoView) : Async = async { + member this.Patch([]clientId : ClientId, id, []value : TodoView) : Async = async { let! updated = service.Patch(clientId, { toModel value with id = id }) - return __.WithUri updated + return this.WithUri updated } [] - member __.Delete([]clientId : ClientId, id): Async = + member _.Delete([]clientId : ClientId, id): Async = service.Execute(clientId, Delete id) [] - member __.DeleteAll([]clientId : ClientId): Async = + member _.DeleteAll([]clientId : ClientId): Async = service.Execute(clientId, Clear) diff --git a/src/Equinox.Core/AsyncBatchingGate.fs b/src/Equinox.Core/AsyncBatchingGate.fs index 027111b55..ce80a75ed 100644 --- a/src/Equinox.Core/AsyncBatchingGate.fs +++ b/src/Equinox.Core/AsyncBatchingGate.fs @@ -20,7 +20,7 @@ type internal AsyncBatch<'Req, 'Res>(dispatch : 'Req[] -> Async<'Res>, linger : /// Attempt to add a request to the flight /// Succeeds during linger interval (which commences when the first caller triggers the workflow via AwaitResult) /// Fails if this flight has closed (caller should generate a fresh, potentially after awaiting this.AwaitCompletion) - member __.TryAdd(item) = + member _.TryAdd(item) = if queue.IsAddingCompleted then false else // there's a race between the IsAddingCompleted check outcome and the CompleteAdding @@ -29,10 +29,10 @@ type internal AsyncBatch<'Req, 'Res>(dispatch : 'Req[] -> Async<'Res>, linger : with :? System.InvalidOperationException -> false /// Await the outcome of dispatching the batch (on the basis that the caller has a stake due to a successful TryAdd) - member __.AwaitResult() = Async.AwaitTaskCorrect task.Value + member _.AwaitResult() = Async.AwaitTaskCorrect task.Value /// Wait for dispatch to conclude (for any reason: ok/exn/cancel; we only care about the channel being clear) - member __.AwaitCompletion() = + member _.AwaitCompletion() = Async.FromContinuations(fun (cont, _, _) -> task.Value.ContinueWith(fun (_ : System.Threading.Tasks.Task<'Res>) -> cont ()) |> ignore) @@ -42,7 +42,7 @@ type AsyncBatchingGate<'Req, 'Res>(dispatch : 'Req[] -> Async<'Res>, ?linger) = let mkBatch () = AsyncBatch(dispatch, defaultArg linger (System.TimeSpan.FromMilliseconds 5.)) let mutable cell = mkBatch() - member __.Execute req = async { + member x.Execute req = async { let current = cell // If current has not yet been dispatched, hop on and join if current.TryAdd req then @@ -51,5 +51,5 @@ type AsyncBatchingGate<'Req, 'Res>(dispatch : 'Req[] -> Async<'Res>, ?linger) = do! current.AwaitCompletion() // where competing threads discover a closed flight, we only want a single one to regenerate it let _ = System.Threading.Interlocked.CompareExchange(&cell, mkBatch (), current) - return! __.Execute req + return! x.Execute req } diff --git a/src/Equinox.Core/AsyncCacheCell.fs b/src/Equinox.Core/AsyncCacheCell.fs index cfd3ede80..5ce856daf 100755 --- a/src/Equinox.Core/AsyncCacheCell.fs +++ b/src/Equinox.Core/AsyncCacheCell.fs @@ -6,7 +6,7 @@ type AsyncLazy<'T>(workflow : Async<'T>) = /// Await the outcome of the computation. /// NOTE due to `Lazy` semantics, failed attempts will cache any exception; AsyncCacheCell compensates for this - member __.AwaitValue() = Async.AwaitTaskCorrect task.Value + member _.AwaitValue() = Async.AwaitTaskCorrect task.Value /// Synchronously check whether the value has been computed (and/or remains valid) member this.IsValid(?isExpired) = @@ -37,9 +37,9 @@ type AsyncCacheCell<'T>(workflow : Async<'T>, ?isExpired : 'T -> bool) = let mutable cell = AsyncLazy workflow /// Synchronously check the value remains valid (to short-circuit an Async AwaitValue step where value not required) - member __.IsValid() = cell.IsValid(?isExpired=isExpired) + member _.IsValid() = cell.IsValid(?isExpired=isExpired) /// Gets or asynchronously recomputes a cached value depending on expiry and availability - member __.AwaitValue() = async { + member _.AwaitValue() = async { let current = cell match! current.TryAwaitValid(?isExpired=isExpired) with | Some res -> return res diff --git a/src/Equinox.Core/Cache.fs b/src/Equinox.Core/Cache.fs index 5c2ae9206..f98b6376b 100755 --- a/src/Equinox.Core/Cache.fs +++ b/src/Equinox.Core/Cache.fs @@ -9,15 +9,15 @@ type CacheItemOptions = [] type CacheEntry<'state>(initialToken: StreamToken, initialState: 'state, supersedes: StreamToken -> StreamToken -> bool) = let mutable currentToken, currentState = initialToken, initialState - member __.UpdateIfNewer(other : CacheEntry<'state>) = - lock __ <| fun () -> + member x.UpdateIfNewer(other : CacheEntry<'state>) = + lock x <| fun () -> let otherToken, otherState = other.Value if otherToken |> supersedes currentToken then currentToken <- otherToken currentState <- otherState - member __.Value : StreamToken * 'state = - lock __ <| fun () -> + member x.Value : StreamToken * 'state = + lock x <| fun () -> currentToken, currentState type ICache = @@ -41,14 +41,14 @@ type Cache(name, sizeMb : int) = | RelativeExpiration relative -> CacheItemPolicy(SlidingExpiration = relative) interface ICache with - member __.UpdateIfNewer(key, options, entry) = async { + member _.UpdateIfNewer(key, options, entry) = async { let policy = toPolicy options match cache.AddOrGetExisting(key, box entry, policy) with | null -> () | :? CacheEntry<'state> as existingEntry -> existingEntry.UpdateIfNewer entry | x -> failwithf "UpdateIfNewer Incompatible cache entry %A" x } - member __.TryGet key = async { + member _.TryGet key = async { return match cache.Get key with | null -> None diff --git a/src/Equinox.Core/Types.fs b/src/Equinox.Core/Types.fs index 4d6a58ab3..a06f95207 100755 --- a/src/Equinox.Core/Types.fs +++ b/src/Equinox.Core/Types.fs @@ -28,9 +28,9 @@ type StopwatchInterval (startTicks : int64, endTicks : int64) = let totalSeconds = double ticks / ticksPerSecond TimeSpan.FromSeconds totalSeconds - member __.StartTicks = startTicks - member __.EndTicks = endTicks - member __.Elapsed = timeSpanFromStopwatchTicks(endTicks - startTicks) + member _.StartTicks = startTicks + member _.EndTicks = endTicks + member _.Elapsed = timeSpanFromStopwatchTicks(endTicks - startTicks) override __.ToString () = let e = __.Elapsed in sprintf "%g ms" e.TotalMilliseconds type Stopwatch = diff --git a/src/Equinox.EventStore/EventStore.fs b/src/Equinox.EventStore/EventStore.fs index f5050e1b3..a1427b7e6 100755 --- a/src/Equinox.EventStore/EventStore.fs +++ b/src/Equinox.EventStore/EventStore.fs @@ -627,13 +627,13 @@ type EventStoreCategory<'event, 'state, 'context> let resolveStream = Stream.create category let loadEmpty sn = context.LoadEmpty sn, initial - member __.Resolve(streamName : FsCodec.StreamName, [] ?option, [] ?context) = + member _.Resolve(streamName : FsCodec.StreamName, [] ?option, [] ?context) = match FsCodec.StreamName.toString streamName, option with | sn, (None|Some AllowStale) -> resolveStream sn option context | sn, Some AssumeEmpty -> Stream.ofMemento (loadEmpty sn) (resolveStream sn option context) /// Resolve from a Memento being used in a Continuation [based on position and state typically from Stream.CreateMemento] - member __.FromMemento(Token.Unpack token as streamToken, state, [] ?context) = + member _.FromMemento(Token.Unpack token as streamToken, state, [] ?context) = Stream.ofMemento (streamToken, state) (resolveStream token.stream.name context None) type private SerilogAdapter(log : ILogger) = diff --git a/tests/Equinox.CosmosStore.Integration/CosmosFixturesInfrastructure.fs b/tests/Equinox.CosmosStore.Integration/CosmosFixturesInfrastructure.fs index 831a91522..8428a864b 100644 --- a/tests/Equinox.CosmosStore.Integration/CosmosFixturesInfrastructure.fs +++ b/tests/Equinox.CosmosStore.Integration/CosmosFixturesInfrastructure.fs @@ -5,7 +5,6 @@ open Domain open FsCheck open Serilog open System -open Serilog.Core type FsCheckGenerators = static member SkuId = Arb.generate |> Gen.map SkuId |> Arb.fromGen @@ -34,7 +33,7 @@ type TestOutputAdapter(testOutput : Xunit.Abstractions.ITestOutputHelper) = use writer = new System.IO.StringWriter() formatter.Format(logEvent, writer) writer |> string |> testOutput.WriteLine - interface Serilog.Core.ILogEventSink with member __.Emit logEvent = writeSerilogEvent logEvent + interface Serilog.Core.ILogEventSink with member _.Emit logEvent = writeSerilogEvent logEvent [] module SerilogHelpers = @@ -114,21 +113,21 @@ module SerilogHelpers = let writeSerilogEvent (logEvent: LogEvent) = logEvent.RenderMessage () |> System.Diagnostics.Trace.WriteLine captured.Add logEvent - interface Serilog.Core.ILogEventSink with member __.Emit logEvent = writeSerilogEvent logEvent - member __.Clear () = captured.Clear() - member __.ChooseCalls chooser = captured |> Seq.choose chooser |> List.ofSeq - member __.ExternalCalls = __.ChooseCalls (function EqxEvent (EqxAction act) -> Some act | _ -> None) - member __.RequestCharges = __.ChooseCalls (function EqxEvent (TotalRequestCharge e) -> Some e | _ -> None) + interface Serilog.Core.ILogEventSink with member _.Emit logEvent = writeSerilogEvent logEvent + member _.Clear () = captured.Clear() + member _.ChooseCalls chooser = captured |> Seq.choose chooser |> List.ofSeq + member x.ExternalCalls = x.ChooseCalls (function EqxEvent (EqxAction act) -> Some act | _ -> None) + member x.RequestCharges = x.ChooseCalls (function EqxEvent (TotalRequestCharge e) -> Some e | _ -> None) type TestsWithLogCapture(testOutputHelper) = let log, capture = TestsWithLogCapture.CreateLoggerWithCapture testOutputHelper /// NB the returned Logger must be Dispose()'d to guarantee all log output has been flushed upon completion of a test - static member CreateLoggerWithCapture testOutputHelper : Logger* LogCaptureBuffer = + static member CreateLoggerWithCapture testOutputHelper : Serilog.Core.Logger * LogCaptureBuffer = let testOutput = TestOutputAdapter testOutputHelper let capture = LogCaptureBuffer() let logger = - Serilog.LoggerConfiguration() + LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Seq("http://localhost:5341") .WriteTo.Sink(testOutput) @@ -136,7 +135,7 @@ type TestsWithLogCapture(testOutputHelper) = .CreateLogger() logger, capture - member __.Capture = capture - member __.Log = log + member _.Capture = capture + member _.Log = log - interface IDisposable with member __.Dispose() = log.Dispose() + interface IDisposable with member _.Dispose() = log.Dispose() diff --git a/tests/Equinox.EventStore.Integration/Infrastructure.fs b/tests/Equinox.EventStore.Integration/Infrastructure.fs index 0343b3c8b..d11aaa5b8 100644 --- a/tests/Equinox.EventStore.Integration/Infrastructure.fs +++ b/tests/Equinox.EventStore.Integration/Infrastructure.fs @@ -38,7 +38,7 @@ type TestOutputAdapter(testOutput : Xunit.Abstractions.ITestOutputHelper) = use writer = new System.IO.StringWriter() formatter.Format(logEvent, writer); writer |> string |> testOutput.WriteLine - interface Serilog.Core.ILogEventSink with member __.Emit logEvent = writeSerilogEvent logEvent + interface Serilog.Core.ILogEventSink with member _.Emit logEvent = writeSerilogEvent logEvent [] module SerilogHelpers = @@ -81,8 +81,8 @@ module SerilogHelpers = let writeSerilogEvent (logEvent: LogEvent) = logEvent.RenderMessage () |> System.Diagnostics.Trace.WriteLine captured.Add logEvent - interface Serilog.Core.ILogEventSink with member __.Emit logEvent = writeSerilogEvent logEvent - member __.Clear () = captured.Clear() - member __.Entries = captured.ToArray() - member __.ChooseCalls chooser = captured |> Seq.choose chooser |> List.ofSeq - member __.ExternalCalls = __.ChooseCalls (function EsEvent (EsAction act) -> Some act | _ -> None) + interface Serilog.Core.ILogEventSink with member _.Emit logEvent = writeSerilogEvent logEvent + member _.Clear () = captured.Clear() + member _.Entries = captured.ToArray() + member _.ChooseCalls chooser = captured |> Seq.choose chooser |> List.ofSeq + member x.ExternalCalls = x.ChooseCalls(function EsEvent (EsAction act) -> Some act | _ -> None) diff --git a/tests/Equinox.MemoryStore.Integration/Infrastructure.fs b/tests/Equinox.MemoryStore.Integration/Infrastructure.fs index b8ccddfd2..3acfef006 100644 --- a/tests/Equinox.MemoryStore.Integration/Infrastructure.fs +++ b/tests/Equinox.MemoryStore.Integration/Infrastructure.fs @@ -20,10 +20,10 @@ type TestOutputAdapter(testOutput : Xunit.Abstractions.ITestOutputHelper) = use writer = new System.IO.StringWriter() formatter.Format(logEvent, writer); writer |> string |> testOutput.WriteLine - interface Serilog.Core.ILogEventSink with member __.Emit logEvent = writeSerilogEvent logEvent + interface Serilog.Core.ILogEventSink with member _.Emit logEvent = writeSerilogEvent logEvent let createLogger sink = LoggerConfiguration() .WriteTo.Sink(sink) .WriteTo.Seq("http://localhost:5341") - .CreateLogger() \ No newline at end of file + .CreateLogger() diff --git a/tools/Equinox.Tool/Program.fs b/tools/Equinox.Tool/Program.fs index 2ba22c2dc..f487b4b8a 100644 --- a/tools/Equinox.Tool/Program.fs +++ b/tools/Equinox.Tool/Program.fs @@ -53,7 +53,7 @@ and []InitArguments = | SkipStoredProc -> "Inhibit creation of stored procedure in specified Container." | Cosmos _ -> "Cosmos Connection parameters." and CosmosInitInfo(args : ParseResults) = - member __.ProvisioningMode = + member _.ProvisioningMode = let throughput () = if args.Contains Autoscale then CosmosInit.Throughput.Autoscale (args.GetResult(Rus, 4000)) @@ -114,7 +114,7 @@ and []DumpArguments = | MySql _ -> "Parameters for MySql." | Postgres _ -> "Parameters for Postgres." and DumpInfo(args: ParseResults) = - member __.ConfigureStore(log : ILogger, createStoreLog) = + member _.ConfigureStore(log : ILogger, createStoreLog) = let storeConfig = None, true match args.TryGetSubCommand() with | Some (DumpArguments.Cosmos sargs) -> @@ -172,43 +172,43 @@ and []TestArguments = | Postgres _ -> "Run transactions in-process against Postgres." | Web _ -> "Run transactions against a Web endpoint." and TestInfo(args: ParseResults) = - member __.Options = args.GetResults Cached @ args.GetResults Unfolds - member __.Cache = __.Options |> List.exists (function Cached -> true | _ -> false) - member __.Unfolds = __.Options |> List.exists (function Unfolds -> true | _ -> false) - member __.Test = args.GetResult(Name,Test.Favorite) - member __.ErrorCutoff = args.GetResult(ErrorCutoff,10000L) - member __.TestsPerSecond = args.GetResult(TestsPerSecond,1000) - member __.Duration = args.GetResult(DurationM,30.) |> TimeSpan.FromMinutes - member __.ReportingIntervals = + member _.Options = args.GetResults Cached @ args.GetResults Unfolds + member x.Cache = x.Options |> List.exists (function Cached -> true | _ -> false) + member x.Unfolds = x.Options |> List.exists (function Unfolds -> true | _ -> false) + member _.Test = args.GetResult(Name,Test.Favorite) + member _.ErrorCutoff = args.GetResult(ErrorCutoff,10000L) + member _.TestsPerSecond = args.GetResult(TestsPerSecond,1000) + member _.Duration = args.GetResult(DurationM,30.) |> TimeSpan.FromMinutes + member x.ReportingIntervals = match args.GetResults(ReportIntervalS) with | [] -> TimeSpan.FromSeconds 10.|> Seq.singleton | intervals -> seq { for i in intervals -> TimeSpan.FromSeconds(float i) } - |> fun intervals -> [| yield __.Duration; yield! intervals |] - member __.ConfigureStore(log : ILogger, createStoreLog) = - let cache = if __.Cache then Equinox.Cache(appName, sizeMb = 50) |> Some else None + |> fun intervals -> [| yield x.Duration; yield! intervals |] + member x.ConfigureStore(log : ILogger, createStoreLog) = + let cache = if x.Cache then Equinox.Cache(appName, sizeMb = 50) |> Some else None match args.TryGetSubCommand() with | Some (Cosmos sargs) -> let storeLog = createStoreLog <| sargs.Contains Storage.Cosmos.Arguments.VerboseStore - log.Information("Running transactions in-process against CosmosDB with storage options: {options:l}", __.Options) - storeLog, Storage.Cosmos.config log (cache, __.Unfolds) (Storage.Cosmos.Info sargs) + log.Information("Running transactions in-process against CosmosDB with storage options: {options:l}", x.Options) + storeLog, Storage.Cosmos.config log (cache, x.Unfolds) (Storage.Cosmos.Info sargs) | Some (Es sargs) -> let storeLog = createStoreLog <| sargs.Contains Storage.EventStore.Arguments.VerboseStore - log.Information("Running transactions in-process against EventStore with storage options: {options:l}", __.Options) - storeLog, Storage.EventStore.config (log,storeLog) (cache, __.Unfolds) sargs + log.Information("Running transactions in-process against EventStore with storage options: {options:l}", x.Options) + storeLog, Storage.EventStore.config (log,storeLog) (cache, x.Unfolds) sargs | Some (MsSql sargs) -> let storeLog = createStoreLog false - log.Information("Running transactions in-process against MsSql with storage options: {options:l}", __.Options) - storeLog, Storage.Sql.Ms.config log (cache, __.Unfolds) sargs + log.Information("Running transactions in-process against MsSql with storage options: {options:l}", x.Options) + storeLog, Storage.Sql.Ms.config log (cache, x.Unfolds) sargs | Some (MySql sargs) -> let storeLog = createStoreLog false - log.Information("Running transactions in-process against MySql with storage options: {options:l}", __.Options) - storeLog, Storage.Sql.My.config log (cache, __.Unfolds) sargs + log.Information("Running transactions in-process against MySql with storage options: {options:l}", x.Options) + storeLog, Storage.Sql.My.config log (cache, x.Unfolds) sargs | Some (Postgres sargs) -> let storeLog = createStoreLog false - log.Information("Running transactions in-process against Postgres with storage options: {options:l}", __.Options) - storeLog, Storage.Sql.Pg.config log (cache, __.Unfolds) sargs + log.Information("Running transactions in-process against Postgres with storage options: {options:l}", x.Options) + storeLog, Storage.Sql.Pg.config log (cache, x.Unfolds) sargs | _ | Some (Memory _) -> - log.Warning("Running transactions in-process against Volatile Store with storage options: {options:l}", __.Options) + log.Warning("Running transactions in-process against Volatile Store with storage options: {options:l}", x.Options) createStoreLog false, Storage.MemoryStore.config () member __.Tests = match args.GetResult(Name,Favorite) with @@ -274,7 +274,7 @@ module LoadTest = decorateWithLogger (log,verbose) execForClient | Some storeConfig, _ -> let services = ServiceCollection() - Samples.Infrastructure.Services.register(services, storeConfig, storeLog) + Services.register(services, storeConfig, storeLog) let container = services.BuildServiceProvider() let execForClient = Tests.executeLocal container test decorateWithLogger (log, verbose) execForClient diff --git a/tools/Equinox.Tool/TodoClient.fs b/tools/Equinox.Tool/TodoClient.fs index 0d2a0543a..737bdf28a 100644 --- a/tools/Equinox.Tool/TodoClient.fs +++ b/tools/Equinox.Tool/TodoClient.fs @@ -18,25 +18,25 @@ type TodosClient(session: Session) = let basePath = "/todos" - member __.List() : Async = async { + member _.List() : Async = async { let request = HttpReq.get () |> HttpReq.withPath basePath let! response = session.Send request return! response |> HttpRes.deserializeOkJsonNet } - member __.Add(x: Todo) = async { + member _.Add(x: Todo) = async { let request = HttpReq.post () |> HttpReq.withPath basePath |> HttpReq.withJsonNet x let! response = session.Send request return! response |> HttpRes.deserializeOkJsonNet } - member __.Update(x: Todo)= async { + member _.Update(x: Todo)= async { let request = HttpReq.patch () |> HttpReq.withUri (Uri x.url) |> HttpReq.withJsonNet x let! response = session.Send request return! response |> HttpRes.deserializeOkJsonNet } - member __.Clear() : Async = async { + member _.Clear() : Async = async { let request = HttpReq.delete () |> HttpReq.withPath basePath let! response = session.Send request return! response.EnsureStatusCode(HttpStatusCode.NoContent) diff --git a/tools/Equinox.Tools.TestHarness/LoadTestRunner.fs b/tools/Equinox.Tools.TestHarness/LoadTestRunner.fs index b7d0949e1..bbc98d3a9 100644 --- a/tools/Equinox.Tools.TestHarness/LoadTestRunner.fs +++ b/tools/Equinox.Tools.TestHarness/LoadTestRunner.fs @@ -28,15 +28,15 @@ module private LocalLoadTestImpl = /// Thread-safe latch type Latch() = let mutable isTriggered = 0 - member __.Enter() = Interlocked.CompareExchange(&isTriggered, 1, 0) = 0 - member __.Reset() = isTriggered <- 0 + member _.Enter() = Interlocked.CompareExchange(&isTriggered, 1, 0) = 0 + member _.Reset() = isTriggered <- 0 /// Thread-safe counter type ConcurrentCounter() = let mutable count = 0L - member __.Increment() = Interlocked.Increment &count - member __.Decrement() = Interlocked.Decrement &count - member __.Value = count + member _.Increment() = Interlocked.Increment &count + member _.Decrement() = Interlocked.Decrement &count + member _.Value = count /// Atomic enum cell type EnumAtom<'Enum when 'Enum : enum>(init : 'Enum) = @@ -45,10 +45,10 @@ module private LocalLoadTestImpl = let mutable state = toInt init /// Atomically updates to newValue assuming that cell is currentValue, /// returning a boolean indicating success - member __.CompareExchange (currentValue : 'Enum) (newValue : 'Enum) : bool = + member _.CompareExchange (currentValue : 'Enum) (newValue : 'Enum) : bool = Interlocked.CompareExchange(&state, toInt newValue, toInt currentValue) = toInt currentValue - member __.Value + member _.Value with get() = fromInt state and set v = state <- toInt v @@ -144,12 +144,12 @@ module private LocalLoadTestImpl = let _ = Async.StartAsTask(allocatorLoop 1L, cancellationToken = cts.Token) - member __.LeaseCount = int leaseCount.Value - member __.AllocationCount = sessions.Count - member __.AvailableSessions = sessions.Count - int leaseCount.Value + member _.LeaseCount = int leaseCount.Value + member _.AllocationCount = sessions.Count + member _.AvailableSessions = sessions.Count - int leaseCount.Value /// Request a session from the pool - member __.TryRequestSession() : Async option> = async { + member _.TryRequestSession() : Async option> = async { let foundPooledSession, sessionId = pooledSessions.TryDequeue() if foundPooledSession then let ctx = sessions.[sessionId]