Replies: 1 comment 1 reply
-
Disclosure up-front: I tend to think about cancellation from the perspective of an app container author, so my views may be under-nuanced w.r.t. the OpenFeature SDK's responsibilities to the OpenFeature spec, so hoping that others will chime in with counterexamples if the picture I'm painting is missing some of those considerations. @toddbaert wrote #207 (comment):
In a somewhat naive way, IMO, cancellation in an upstream library means stop, drop, and roll.
If we're in a method like For calls into methods like I don't think that cancellation anywhere else in the SDK should trigger
I can see where you're coming from here, but I actually think this^ would be really dangerous. For example (admittedly a very contrived example...): using var cts = CancellationTokenSource.CreateLinkedTokenSource(default(CancellationToken));
cts.Cancel();
if (await featureClient.GetBooleanAsync("should-delete-all-client-data", false, cts.Token).ConfigureAwait(false))
{
// yay, delete all the data!
}
else
{
// okay, fine, only delete some of that data...
} |
Beta Was this translation helpful? Give feedback.
-
Hey OpenFeature .NET folks!
Recently there's been some proposed changes to the SDK for more idiomatic async method names, as well as cancellation token support. We now have a
SetProviderAsync
method, and here some changes to the flag evaluation methods and provider resolvers were pitched as well.The proposed method names and signatures are consistent with .NET standard lib functions and popular libraries, so I'm in favor. However, I think we need to solidify semantics around the cancellation tokens in particular; for the SDK, and for providers, what does cancellation mean? I think it's clear that a cancellation would probably cause a flag evaluation to default, but I'm less sure about the implications on methods that imply some kind of state change (like
SetProviderAsync
orShutdown
).My initial thought was that cancellation of any such methods should probably result in the implied end-state being reached, but cancel any asynchronous actions, for example:
setProviderAsync
would result in the provider being set, but the provider may now being in an error state (since it's initialization was cancelled)shutdown
would still shut down the SDK and all providers, but asynchronous work (such as flushing telemetry or gracefully tearing-down connections) may have been cancelledThere may be more examples. I think we need to iron this out so we can give some direction to provider-authors and API users before we release these changes.
Beta Was this translation helpful? Give feedback.
All reactions