Open alex-bortnik opened 2 years ago
Hi @alex-bortnik - we just closed an issue yesterday about this, and we provided an option for users to configure timeouts on these requests, which sounds like would be helpful to you. Can you take a look at https://github.com/statsig-io/dotnet-sdk/issues/12 and see if that works first?
I see that you've added cancellation tokens to functions like CheckGate
- these functions are async but should actually return instantaneously because it just performs a local evaluation, so I'm not sure if cancellation token is really needed here.
Hi @jkw-statsig - yes, I saw that, my PR is based on #12 implementation. This PR allows to provide either timeout or cancellation token.
Override with optional cancellation token is added only to the public methods which are calling RequestDispatcher.Fetch
(where actual http request is being sent).
Implementation of RequestDispatcher.Fetch
is switched from WebRequest
to HttpClient
which has better async support. Also WebRequest
is already declared obsolete: https://docs.microsoft.com/en-us/dotnet/core/compatibility/networking/6.0/webrequest-deprecated
Also, the common practice in .NET/C# is to pass cancellation token downstream from upper layer. It is not possible to get remaining timeout value from cancellation token downstream. Plus there could be other reasons for cancellation apart from timeout.
Got it, thanks for the context. We'll take a look into your patch
@jkw-statsig any update on this?
Hi,
we would like to add cancellation tokens support for async methods. I prepared PR (see patch in attachment). It also includes update from obsolete
WebRequest
toHttpClient
(please rename from txt -> patch)
cancellation_token_support_for_async_methods.txt .