open-feature / dotnet-sdk

.NET implementation of the OpenFeature SDK
https://openfeature.dev
Apache License 2.0
62 stars 17 forks source link

refactor: Use ValueTask on plumbing methods #185

Closed austindrenski closed 4 months ago

austindrenski commented 8 months ago

Switch to ValueTask on methods that are likely to complete synchronously and/or be populated with contrib-/user-provided delegates.

See: #184


This follows #184 with an idea (probably best punted for post-2.0.0) to switch plumbing-type methods from Task to ValueTask to take advantage of the zero-cost-sync-completion sugar that the dotnet/runtime folks have generously given us to play with.

I've got a bigger PR planned where I'll propose returning ValueTask<T> on the IFeatureClient methods in order to hide a TTL caching layer that users can use to amortize provider requests (e.g. users could configure IFeatureClient to cache a value for flag K for N seconds, and for those N seconds any subsequent requests to any IFeatureClient for flag K would result in a sync read from a memory cache).

But that's for later, and for now this PR just looks to make those user-/contrib-provided plumbing methods super lightweight on the scalding hotpath.

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (1a14f6c) 0.00% compared to head (0c7fabf) 94.11%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #185 +/- ## ========================================= + Coverage 0 94.11% +94.11% ========================================= Files 0 23 +23 Lines 0 951 +951 Branches 0 101 +101 ========================================= + Hits 0 895 +895 - Misses 0 32 +32 - Partials 0 24 +24 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

toddbaert commented 4 months ago

I've started updating this and https://github.com/open-feature/dotnet-sdk/pull/184

toddbaert commented 4 months ago

Closing and continuing with https://github.com/open-feature/dotnet-sdk/pull/268