Giter Site home page Giter Site logo

tmc's Introduction

Build Status Maven Central Javadocs

Tagged Modular Configuration

  • Java configuration library. Read and map your config file(s) to a POJO.
  • Modular: Reference other config files on the classpath to merge into your config.
  • Tagged: Define config blocks with tags to merge config at runtime.
  • Formats: JSON and YAML

Usage:

    MyConfig config = TaggedModularConfig.rootModule("main").applyTags("prod").create(MyConfig.class);
  • TMC modules have filename patterns <module name>.tmc.<format> (ex: main.tmc.json, config.tmc.yml)
  • Modules are referenced using the "_module" field name. The module file will be loaded and merged into the node the "_module" was found on.
  • Tags are defined on a module root using the "_tags" field name. Tags specified at runtime will be merged onto the module at the root level, so full paths are needed in tag blocks.
  • TMC modules can reference other modules. TMC will resolve modules recursively, and error if a cycle is detected. Tags can also contain modules.
  • Collision precedence order: root tags > root tree > module tags > module tree. Module tags will be resolved before the module is merged into it's parent tree. Module merging will not overwrite existing leafs of the parent module. Tag merging will overwrite existing leafs of the parent module. Multi-tag collisions will be won by the firstmost tag of the applied tag list.
//main.tmc.json
{
  "app": "example",
  "logging": {
    "level": "DEBUG",
    "enabled": true
  },
  "http": {
    "_module": "loadbalancer",
    "port": 8080
  },
  "_tags": {
    "prod": {
      "logging": {
        "level": "WARN"
      }
    }
  }
}
//loadbalancer.tmc.json
{
  "host": "localhost",
  "timeout": "5s",
  "_tags": {
    "prod": {
      "host": "lb.site.com"
    }
  }
}

Running TMC on the "main" module with the "prod" tag would create the config below.

{
  "app": "example",          //root tree
  "logging": {               //root tree
    "level": "WARN",         //root tag
    "enabled": true          //root tree
  },
  "http": {                  //root tree
    "host": "lb.site.com",   //module tag
    "timeout": "5s",         //module tree
    "port": 8080             //root tree
  }
}
<dependency>
  <groupId>io.github.yeagy</groupId>
  <artifactId>tmc</artifactId>
  <version>0.2.0</version>
</dependency>

tmc's People

Contributors

yeagy avatar

Watchers

 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.