Giter Site home page Giter Site logo

dotnet-sdk's Introduction

Unlaunch .NET SDK

main development
Build Status Build Status

Overview

The Unlaunch .NET SDK provides .NET Framework or .NET Core API to access Unlaunch feature flags and other features. Using the SDK, you can easily build .NET applications that can evaluate feature flags, dynamic configurations, and more.

Important Links

Compatibility

.NET Framework 4.5+ and .NET Core 2.0+

This is a server-side SDK

This SDK is server-side and should be used in applications that you run on your own servers such as backend services or web servers. For more information, see this.

Getting Started

Here is a simple example.

First import the SDK using Nuget.

Install-Package unlaunch -Version 1.0.0

Here's an example showing how you'd use Unlaunch .NET SDK in your application.

using System;
using io.unlaunch;

namespace your.namespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // initialize the client
            var client = UnlaunchClient.Create("INSERT_YOUR_SDK_KEY");

            // wait for the client to be ready
            try
            {
                client.AwaitUntilReady(TimeSpan.FromSeconds(2));
            }
            catch (TimeoutException e) {
                Console.WriteLine("client wasn't ready " + e.Message);
            }
            
            // get variation
            var variation = client.GetVariation("flagKey", "userId123");

            // take action based on the returned variation
            if (variation == "on")
            {
                Console.WriteLine("Variation is on");
            }
            else if (variation == "off")
            {
                Console.WriteLine("Variation is off");
            }
            else
            {
                Console.WriteLine("control variation");
            }

            // If you attached (key-value) configuration to your feature flag variations, 
            // here's how you can retrieve it:
            var feature = client.GetFeature("new_login_ui", "userId");
            var colorHexCode = feature.GetVariationConfig().GetString("login_btn_clr", "#cd5c5c");

            // shutdown the client to flush any events or metrics 
            client.Shutdown();
        }
    }
}

Singleton in web application

var unlaunchClient = UnlaunchClient.Create("INSERT_YOUR_SDK_KEY");
builder.Register(c => unlaunchClient).As<IUnlaunchClient>().SingleInstance();

Customization

You can use builder to customize the client. For more information, see the official guide.

var client = UnlaunchClient.Builder()
                .SdkKey("INSERT_YOUR_SDK_KEY")
                .PollingIntervalInSeconds(TimeSpan.FromSeconds(60))
                .EventsFlushIntervalInSeconds(TimeSpan.FromSeconds(30))
                .EventsQueueSize(500)
                .MetricsFlushIntervalInSeconds(TimeSpan.FromSeconds(30))
                .MetricsQueueSize(100)
                .Build();

License

Licensed under the Apache License, Version 2.0. See: Apache License.

dotnet-sdk's People

Contributors

tnguyenquy avatar umermansoor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar  avatar  avatar

Forkers

mysticbacon

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.