.NET
Installation
Install the Tggl
package:
Quick start
Instantiate a client with your API key and call EvalContext
to evaluate a context. A single API call evaluating all flags is performed, making all subsequent flag checking methods extremely fast.
This means that you do not need to cache results of GetX
methods since they do not trigger an API call, they simply look up the data in the already fetched response.
Different value types
You can get the value of a flag as a boolean, string, integer, double, list, or dictionary:
Those methods are guaranteed to return the expected type. The default value is returned if the flag does not exist (or in case of network errors) or if its value is not of the expected type.
Alternatively you can call Get
which does not perform any type conversion:
Get
will always return the value of the flag if it exists, even if that value is null
, and will return the default value otherwise.
The context object
The flag evaluation context can be either a specific class, an anonymous object, or a Dictionary.
Evaluating contexts in batches
If you have multiple contexts to evaluate at once, you can batch your calls in a single HTTP request which is much more performant:
Reporting
By default, the SDK sends flag evaluation data to Tggl to give you precious insights on how you are actually using your flags in production and to help you manage flags lifecycles better.
The SDK sends at most one HTTP request every 5 seconds to Tggl. Additionally, you can identify the client making the request by giving it an app name. You will be able to retrieve that name on the Tggl dashboard:
You can also disable reporting entirely:
Using the Proxy
By default, the SDK talks directly to the Tggl API. If you are using the Tggl Proxy, you can specify the proxy URL when instantiating the client:
The /flags
and /report
path will be appended to the BaseUrl
and both flags evaluation and reporting will go through the proxy. If your proxy is configured with custom paths, you can specify them:
Evaluate flags locally
It is possible to evaluate flags locally on the server but not recommended unless you have performance issues evaluating flags at a high frequency. Evaluating flags locally forces you to maintain the copy of flags configuration up to date and might be a source of issues.
Make sure to add the right keys to your context to be perfectly consistent with the Tggl API.
The config will be fetched every 5 seconds by default. You can change this interval by passing a PollingInterval
parameter to the constructor.
Note that client.Ready()
will return immediately if the config has already been fetched, it only waits for the first initial config.