EXPERIMENTAL
EXPERIMENTAL
Assumption. All keys should start with -
This source supports almost all standard command-line patterns including nesting/sub-config, repetition/list etc
Example:
Given:
args = "-db.username=1 --db.password=hi --vault -username=3 --vault -password=10 --regions 111,122 --user k1 --user k2" keyDelimiter = Some('.') valueDelimiter = Some(',')
then, the following works:
final case class Credentials(username: String, password: String) val credentials = (string("username") |@| string("password"))(Credentials.apply, Credentials.unapply) final case class Config(databaseCredentials: Credentials, vaultCredentials: Credentials, regions: List[String], users: List[String]) (nested("db") { credentials } |@| nested("vault") { credentials } |@| list("regions")(string) |@| list("user")(string))(Config.apply, Config.unapply) // res0 Config(Credentials(1, hi), Credentials(3, 10), List(111, 122), List(k1, k2))
Provide keyDelimiter if you need to consider flattened config as a nested config.
Provide keyDelimiter if you need to consider flattened config as a nested config. Provide valueDelimiter if you need any value to be a list
Example:
Given:
map = Map("KAFKA_SERVERS" -> "server1, server2", "KAFKA_SERDE" -> "confluent") keyDelimiter = Some('_') valueDelimiter = Some(',')
then, the following works:
final case class kafkaConfig(server: String, serde: String) nested("KAFKA")(string("SERVERS") |@| string("SERDE"))(KafkaConfig.apply, KafkaConfig.unapply)
leafForSequence indicates whether a Leaf(value) (i.e, a singleton) could be considered a Sequence.
Provide keyDelimiter if you need to consider flattened config as a nested config.
Provide keyDelimiter if you need to consider flattened config as a nested config.
Example:
Given:
map = Map("KAFKA_SERVERS" -> singleton(server1), "KAFKA_SERDE" -> singleton("confluent")) keyDelimiter = Some('_')
then, the following works:
final case class kafkaConfig(server: String, serde: String) nested("KAFKA")(string("SERVERS") |@| string("SERDE"))(KafkaConfig.apply, KafkaConfig.unapply)
leafForSequence indicates whether a Leaf(value) (i.e, a singleton) could be considered a Sequence.
Provide keyDelimiter if you need to consider flattened config as a nested config.
Provide keyDelimiter if you need to consider flattened config as a nested config. Provide valueDelimiter if you need any value to be a list
Example:
Given:
property = "KAFKA.SERVERS" = "server1, server2" ; "KAFKA.SERDE" = "confluent" keyDelimiter = Some('.') valueDelimiter = Some(',')
then, the following works:
final case class kafkaConfig(server: String, serde: String) nested("KAFKA")(string("SERVERS") |@| string("SERDE"))(KafkaConfig.apply, KafkaConfig.unapply)
leafForSequence indicates whether a Leaf(value) (i.e, a singleton) could be considered a Sequence.
Provide keyDelimiter if you need to consider flattened config as a nested config.
Provide keyDelimiter if you need to consider flattened config as a nested config. Provide valueDelimiter if you need any value to be a list
Example:
Given:
properties (in file) = "KAFKA.SERVERS" = "server1, server2" ; "KAFKA.SERDE" = "confluent" keyDelimiter = Some('.') valueDelimiter = Some(',')
then, the following works:
final case class kafkaConfig(server: String, serde: String) nested("KAFKA")(string("SERVERS") |@| string("SERDE"))(KafkaConfig.apply, KafkaConfig.unapply)
leafForSequence indicates whether a Leaf(value) (i.e, a singleton) could be considered a Sequence.
To obtain a config source directly from a property tree.
To obtain a config source directly from a property tree.
: PropertyTree
: Label the source with a name
: Should a single value wrapped in Leaf be considered as Sequence
Consider providing keyDelimiter if you need to consider flattened config as a nested config.
Consider providing keyDelimiter if you need to consider flattened config as a nested config. Consider providing valueDelimiter if you need any value to be a list
Example:
Given:
vars in sys.env = "KAFKA_SERVERS" = "server1, server2" ; "KAFKA_SERDE" = "confluent" keyDelimiter = Some('_') valueDelimiter = Some(',')
then, the following works:
final case class kafkaConfig(server: String, serde: String) nested("KAFKA")(string("SERVERS") |@| string("SERDE"))(KafkaConfig.apply, KafkaConfig.unapply)
Note: The delimiter '.' for keys doesn't work in system environment.
For users that dont want to use layers in their application This method provides live system environment layer
Consider providing keyDelimiter if you need to consider flattened config as a nested config.
Consider providing keyDelimiter if you need to consider flattened config as a nested config. Consider providing valueDelimiter if you need any value to be a list
Example:
Given:
vars in sys.env = "KAFKA.SERVERS" = "server1, server2" ; "KAFKA.SERDE" = "confluent" keyDelimiter = Some('.') valueDelimiter = Some(',')
then, the following works:
final case class kafkaConfig(server: String, serde: String) nested("KAFKA")(string("SERVERS") |@| string("SERDE"))(KafkaConfig.apply, KafkaConfig.unapply)