scoped-config


License

License

MIT
Categories

Categories

config Application Layer Libs Configuration
GroupId

GroupId

com.gilt
ArtifactId

ArtifactId

scoped-config_2.11
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

scoped-config
scoped-config
Project URL

Project URL

https://github.com/gilt/scoped-config
Project Organization

Project Organization

com.gilt
Source Code Management

Source Code Management

https://github.com/gilt/scoped-config.git

Download scoped-config_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.gilt/scoped-config_2.11/ -->
<dependency>
    <groupId>com.gilt</groupId>
    <artifactId>scoped-config_2.11</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.gilt/scoped-config_2.11/
implementation 'com.gilt:scoped-config_2.11:0.0.1'
// https://jarcasting.com/artifacts/com.gilt/scoped-config_2.11/
implementation ("com.gilt:scoped-config_2.11:0.0.1")
'com.gilt:scoped-config_2.11:jar:0.0.1'
<dependency org="com.gilt" name="scoped-config_2.11" rev="0.0.1">
  <artifact name="scoped-config_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gilt', module='scoped-config_2.11', version='0.0.1')
)
libraryDependencies += "com.gilt" % "scoped-config_2.11" % "0.0.1"
[com.gilt/scoped-config_2.11 "0.0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.6
com.typesafe : config jar 1.2.1
com.typesafe.scala-logging : scala-logging_2.11 jar 3.1.0

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.11 jar 2.2.4

Project Modules

There are no modules declared in this project.

scoped-config

This provides helper code for getting scoped configs for a production environment.

Build Status Codacy Badge

typesafehub/config provides a very flexible config library, but it may be flexible to a fault in that it's not clear on how to just setup a simple configuration that has scoped overrides for production values. This library tries to fill that gap.

Installation

For Scala 2.11 with Java 7 or higher.

##sbt dependency:

libraryDependencies += "com.gilt" %% "scoped-config" % "0.0.1"

Usage

It should work if as if you are using the default ConfigFactory.load() function, but it takes a scope which will be pulled up to the root of the config if it's there falling back to the default again.

If your config looked like this:

foo = "default"
beta.foo = "beta-scoped-foo"
prod.foo = "prod-scoped-foo"

bar = "baz"

You can get a prod scoped config like this:

import com.gilt.config.ScopedConfigFactory

ScopedConfigFactory.load("prod")

That config would look as though you had a config like this:

foo = "prod-scoped-foo"

bar = "baz"

A beta scoped conf would look like this:

foo = "beta-scoped-foo"

bar = "baz"

Notice we don't have any values scoped to gamma but we could still get a gamma scoped conf which would just look like the default one:

foo = "default"

bar = "baz"

Complex scopes

More complex scopes have limited support. For example if you had a more complex scope that was formed of .. Then you could have scopes like US.Prod and GB.Test.

There isn't any support for any wildcards though, so not sure how useful that is yet. If there's demand, maybe we could figure out how to add it.

Limitations

It won't remove the other scopes from your config. So from the above example if you had a prod scoped config, you could see the beta values if you want like this:

ScopedConfigFactory.load("prod").getString("beta.foo") // "beta-scoped-foo"

I think this is unavoidable without limiting the values that can be used for scopes and is a trade-off you get for multiplexing a single simple configuration into many scoped configurations.

com.gilt

Gilt Tech

Versions

Version
0.0.1