jet / dotnet-templates

Example app and service templates `dotnet new -i Equinox.Templates; dotnet new eqx*/pro*` https://github.com/jet/equinox https://github.com/jet/FsCodec
https://github.com/jet/propulsion
Apache License 2.0
64 stars 16 forks source link

Simplify resolve functions #54

Closed bartelink closed 4 years ago

bartelink commented 4 years ago

This is part of style cleanup in #53

This pushes out a common helper method (resolve), and its shadowing outside of the type Service, but has the following properties:

Replaces the form:

type Service internal (log, resolve, maxAttempts) =

    let resolve id =
        let stream = resolve (streamName id)
        Equinox.Stream<Events.Event, Fold.State>(log, stream, maxAttempts)

with

type Service internal (resolve : string -> Equinox.Stream<Events.Event,Fold.State>) =

and

let create resolve =
    let resolver id =
        let stream = resolve (streamName id)
        Equinox.Stream(Serilog.Log.ForContext<Service>(), stream, maxAttempts = 3)
    Service(resolver)

@thednaz