Coder Social home page Coder Social logo

configcat / .net-sdk Goto Github PK

View Code? Open in Web Editor NEW
27.0 27.0 8.0 1.53 MB

ConfigCat SDK for .NET. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.

Home Page: https://configcat.com/docs/sdk-reference/csharp

License: Other

C# 99.92% PowerShell 0.04% Batchfile 0.04%
configcat configuration configuration-management dotnet dotnetcore feature-flag feature-flags feature-toggle feature-toggles featureflags netstandard remote-config

.net-sdk's Issues

Improper use of Task .Result when making async methods sync

Hi!
We've ran into issues with our ThreadPool that was caused by the non async methods on the IConfigCatClient interface called too often in our application. Below are references to the lines in the client that calls .Result and needs to be refactored.
The use of .Result on an async method is very dangerous and produces deadlocks. It should be refactored to either .GetAwaiter().GetResult() or or something like this snippet, from some years ago, (microsofts entity framework team used this to get async methods run sync).

public static class AsyncUtility
{
private static readonly TaskFactory _myTaskFactory = new TaskFactory(
	CancellationToken.None,
	TaskCreationOptions.None,
	TaskContinuationOptions.None,
	TaskScheduler.Default);

public static TResult RunSync<TResult>(Func<Task<TResult>> func)
{
	return _myTaskFactory
			.StartNew<Task<TResult>>(func)
			.Unwrap<TResult>()
			.GetAwaiter()
			.GetResult();
}

public static void RunSync(Func<Task> func)
{
	_myTaskFactory
			.StartNew<Task>(func)
			.Unwrap()
			.GetAwaiter()
			.GetResult();
}
}

var c = this.configService.GetConfigAsync().Result;

return this.GetAllKeysAsync().Result;

var c = this.configService.GetConfigAsync().Result;

var c = this.configService.GetConfigAsync().Result;

New Release with LoggerWrapper fix #39

Is your feature request related to a problem? Please describe.

We set logger level = Error, but we still get some Debug output.
Screenshot 2022-09-06 at 12 30 45

I deep dived into the decompiled code and saw the issue, however when checking out the code i saw that the issue already has been solved via #39

Describe the solution you'd like

A new release of the .net-sdk with the logger wrapper fix, i guess this just was overlooked or perhaps you have some release cycle that you are following.

Describe alternatives you've considered

Just wait for a new release with the fix ๐Ÿ™๐Ÿฝ
Thanks in advance ๐Ÿ‘‹๐Ÿฝ

Deadlock risk due to GetAwaiter().GetResult()

See

var config = this.configService.GetConfigAsync().GetAwaiter().GetResult();

... and it also seems completely unnecessary in the auto polling mode.

In auto polling mode, with in memory cache, you would expect the cache to be a lazy instance of a typed config (see issue #22). This would make the client in essence synchronous (with non-blocking IO in the background while polling).

Now, due to the general pattern (everything async), the synchronous GetValue method can't follow the async-all-the-way pattern and presents a risk to any applications using the client.

json deserialization invoked too many times

Hi,
One of our use cases is getting all enabled features for user. During development we've noticed that every method ConfigCatClient class is directly or indirectly deserializing settings json file, which is causing some performance issues. Was this intended behavior or do you think it could be changed that deserialization happens once after file is refreshed.

Replace IConfigCatLogger with Microsoft.Extensions.Logging.ILogger

Is your feature request related to a problem? Please describe.

Minor inconvenience of having to author an adapter between IConfigCatLogger and Microsoft.Extensions.Logging.ILogger

Describe the solution you'd like

Be able to inject an Microsoft.Extensions.Logging.ILogger into ConfigCatClient factory method.

Describe alternatives you've considered

N/A

Additional context

N/A

Requesting removal of Newtonsoft.Json

Is your feature request related to a problem?

Yes and no ๐Ÿ™ƒ

Describe the solution you'd like

I'd like to see the dependency to Newtonsoft.Json removed in favor of System.Text.Json and perhaps a compiled version targeting dotnet 6, to get full benefits of the latest framework version.

Additional context

Newtonsoft.Json is extremely slow compared to modern json libraries, It's also nice if we can get a smaller list of dependencies into our solution. Considering the launch of dotnet5 last year, Newtonsoft is no longer the go-to solution for handling json in dotnet, unless there is a feature gap that is too hard to re-implement with System.Text.Json.

Is string.Empty a valid argument for the User constructor?

What are valid values for the identifier argument in the User constructor? Specifically, is string.Empty valid, or will this result in unexpected behavior? I partly ask because the Java SDK appears to throw an exception when passing "" whereas this .NET SDK does not.

Also, would you consider making a parameterless constructor for User? Our use case is such that we only care about evaluating rules based on custom attributes, not user ids.

Thanks in advance.

ConfigCat.Client makes a lot of requests

Hi,

We use ConfigCat.Client Version 2.2.1.
We notice a lot of calls happening within the same operation.
Most of them (1153) return with a HTTP statuscode 304 Not Modified and some (289) return with a 200 OK.
Still we would not expect this many calls within the same operation.
How could we provide you with more information to help debug this issue?

Provide change notifications in the .Net client

We use ConfigCat for feature flags and for dynamic configuration in general. Most values are consulted on a per-request basis, but some configuration values apply to the entire host process (e.g. a minimum thread count for the thread pool).

Since these values are not evaluated per request, it would be nice to subscribe to change notifications for these values.

Describe the solution you'd like

We're using ConfigCat in auto polling mode. The client could look for changes in the config every time it receives a new config and raise a .Net event for every changed value.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.