Coder Social home page Coder Social logo

drneil / configcat-configuration-provider Goto Github PK

View Code? Open in Web Editor NEW

This project forked from musement/configcat-configuration-provider

0.0 0.0 0.0 56 KB

A .NET configuration provider for ConfigCat

License: MIT License

C# 93.31% Dockerfile 6.69%

configcat-configuration-provider's Introduction

Build status Nuget package

This repository contains a provider for Microsoft.Extensions.Configuration that maps configuration stored in ConfigCat

Overview

Storing configuration and feature flags in environment variables or appsettings.json may require a new deploy of the application to update something in some cases. This package extends the default configuration pipeline used in ASP.NET applications (or any other application that uses Microsoft.Extensions.Configuration really) to take advantage of remote configuration via ConfigCat.

The repo contains a sample application, but this is how an application will look like:

public class Program
{
    public static Task Main(string[] args)
    {
        Host.CreateDefaultBuilder(args)
            .ConfigureAppConfiguration((hostingContext, builder) =>
            {
                builder.AddConfigCat(configCatOptions =>
                {
                    configCatOptions.Configuration = c =>
                    {
                        c.SdkKey = YOUR_SDK_KEY;
                    };
                })
            })
            .Build()
            .Run();
    }
}

We recommend storing the SDK key in a secure location, like AWS SecretsManager or Azure KeyVault.

Configuration

You can use the lambda parameter in the AddConfigCat extension method to customize the behavior of the application.

The first obvious part is the Configuration property, which is then passed to the ConfigCat SDK internally. This is an AutoPollConfiguration because the library will automatically update the configuration on a timer, which you can configure from this object. You can get more info about this object in the official ConfigCat SDK docs.

The options object also lets you set a filter (KeyFilter ) for the keys you want to import, this is just a lambda function that returns true or false respectively if you want to import a configuration key or not. The default always returns true.

The KeyMapper lambda lets you customize how the ConfigCat key is transformed into a IConfiguration key. The default works like how environment variables work with IConfiguration, with double underscores (__) being transformed in section delimiters so that FOO__BAR gets mapped as FOO:BAR.

Last but not least, the CreateClient lambda gives you an opportunity to override how the ConfigCat client is created. The Configuration object from above is passed as the only parameter.

Versioning

This library follows Semantic Versioning for the public releases.

Releases

Packages are automatically built and published on nuget by a Github Actions workflow triggered by tags.

How to build

This project uses the default dotnet CLI.

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.