GithubHelp home page GithubHelp logo

isabella232 / configmanager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mixpanel/configmanager

0.0 0.0 0.0 33 KB

A library for adding dynamic configuration to your code

License: MIT License

Go 93.87% Python 2.54% Makefile 3.60%

configmanager's Introduction

Configmanager

Configmanager is the what mixpanel uses to add dynamic configuration to our code across several services.

Configmanager does these things:

  • Reads a file configs.json under a specified path, and watches it for changes
  • Interprets the data in the file and gives an easy interface to access the configuration values

Here is a possible example for a hypothetical service called my-service

  cm, err := configmanager.NewClient("/etc/configs", "my-service", fr)
  if err != nil {
  	return err
  }
  defer cm.Close()
  if cm.GetBoolean("my-feature-enabled", false) {
  	// do the my-feature thing
  }

The only requirement for this example to work is placing marshalled configurations in the file /etc/configs/my-service/configs.json

How are configs written

Mixpanel writes configs using JSONNET and they are mounted using kubernetes configmaps. However configmanager only cares about the format and a file that follows the path /dir-path/[name of config group]/configs.json

Two key things you need to unerstand are:

  • Config group: A group of configs that belong together in same scope, because they are used by same feature or same service etc
  • Config: A key, value pair where value can be an arbitrary JSON and you call configmanager methods specifiying the key

A config group marshalled in a file looks like this:

[
  {
    "key": "feature_enabled_customers",
    "value": {
      "123": {},
      "456": {}
    }
  },
  {
    "key": "scaling_percentage",
    "value": 1
  },
  {
    "key": "timeout_secs",
    "value": 5
  }
]

If such a config is placed in the file /etc/configs/my-configs/configs.json then the configmanager will be constructed using configmanager.NewClient("/etc/configs", "my-configs", fr)

configmanager's People

Contributors

nikunjy avatar

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.