Description
Nano-library which provides the ability to define typesafe (!) Configuration templates for applications.
Configur8 alternatives and similar libraries
Based on the "Configuration" category.
Alternatively, view Configur8 alternatives based on common mentions on social networks and blogs.
-
centraldogma
Highly-available version-controlled service configuration repository based on Git, ZooKeeper and HTTP/2 -
Gestalt
A Java configuration library that allows you to build your configurations from multiple sources, merges them and convert them into an easy-to-use typesafe configuration class. A simple but powerful interface allows you to navigate to a path within your configurations and retrieve a configuration object, list, or a primitive value.
WorkOS - The modern identity platform for B2B SaaS
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Configur8 or a related project?
README
Configur8
Nano-library which provides the ability to define typesafe (!) Configuration templates for applications.
Concept:
A Configuration
is a set of named and typed Property
instances, which are defined using a ConfigurationTemplate
.
Each defined Property can be set with a default value, or be blank with a requirement to be overridden. At runtime, the template is reified
into a concrete Configuration
object, but if any properties are missing this process will throw a Misconfiguration
error.
Assuming that the reification process is successful, property values can be retrieved in an (actually) type-safe manner, and are applied in the following descending order of precedence:
- JVM system property
- Named environment property
- Default value
Quick example
This is from the Kotlin version, but the Scala and Java APIs are broadly the same:
// simple typed values
val USER = Property.string("USER")
val AGE = Property.int("AGE")
// provide custom mapping functions to convert from strings to domain
val PATIENCE_LEVEL = Property("DURATION", { i: String -> Duration.parse(i) }, { it.describe() })
// build your template
val configTemplate = ConfigurationTemplate()
.requiring(USER) // will be supplied by the environment
.withProp(AGE, 2) // falls back to a default typed value
.withProp(PATIENCE_LEVEL, Duration(10)) // custom typed property with default
// attempting to build a configuration with missing values will fail with a Misconfiguration exception
val config = configTemplate.reify()
// retrieval of values in a typesafe way
val patience: Duration = config.valueOf[PATIENCE_LEVEL]
Get it:
Currently, the library is published in Java, Kotlin and Scala versions in JCenter (and synced to Maven Central).
Maven:
Java:
<dependency>
<groupId>io.github.daviddenton</groupId>
<artifactId>configur8</artifactId>
<version>1.7.0</version>
</dependency>
Kotlin:
<dependency>
<groupId>io.github.daviddenton</groupId>
<artifactId>konfigur8</artifactId>
<version>1.7.0</version>
</dependency>
SBT:
libraryDependencies += "io.github.daviddenton" %% "configur8" % "1.7.0"