cognitedata / oryx

.NET Cross platform and highly composable middleware for building web request handlers in F#
Apache License 2.0
202 stars 10 forks source link

Howto "pre-compile" parameterized pipelines #24

Closed dbrattli closed 4 years ago

dbrattli commented 4 years ago

Optimally we should "pre-compile" the combinator pipelines by applying the next parameter, usually finishEarly which is the same thing as Ok >> Task.FromResult. However this is not that easy for parameterised pipelines such as https://github.com/cognitedata/cognite-sdk-dotnet/blob/master/src/assets/ListAssets.fs#L61 since it needs the request content and thus we need to "compile" the pipeline for every request. How can we make such a pipeline "compiled" once for all requests?

    let listCore (options: AssetQuery seq) (filters: AssetFilter seq) (fetch: HttpHandler<HttpResponseMessage, 'a>) =
        let request : Request = {
            Filters = filters
            Options = options
        }

        POST
        >=> setVersion V10
        >=> setContent (Content.JsonValue request.Encoder)
        >=> setResource Url
        >=> fetch
        >=> withError decodeError
        >=> json AssetItemsReadDto.Decoder

Ref: https://medium.com/@gerardtoconnor/carry-on-continuation-over-binding-pipelines-for-functional-web-58bd7e6ea009

dbrattli commented 4 years ago

Closing since this will not make things significantly faster.