package gen
- Alphabetic
- By Inheritance
- gen
- DeriveGenInstances
- GenerateConfig
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- trait DeriveGenInstances extends AnyRef
DeriveGenInstances gives instance for DeriveGen for all the types that zio-config supports.
DeriveGenInstances gives instance for DeriveGen for all the types that zio-config supports. It will also make sure the randomness for these types is constrained to produce an almost valid config for the users.
- trait GenerateConfig extends AnyRef
- implicit class UnsafeRunOps[E, A] extends AnyRef
- Definition Classes
- GenerateConfig
Value Members
- implicit def deriveGenBigDecimal: DeriveGen[BigDecimal]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenBigInt: DeriveGen[BigInt]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenByte: DeriveGen[Byte]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenDouble: DeriveGen[Double]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenDuration: DeriveGen[Duration]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenFile: DeriveGen[File]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenFloat: DeriveGen[Float]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenInstant: DeriveGen[Instant]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenInt: DeriveGen[Int]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenJavaFilePath: DeriveGen[Path]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenList[A](implicit arg0: DeriveGen[A]): DeriveGen[List[A]]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenLocalDate: DeriveGen[LocalDate]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenLong: DeriveGen[Long]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenMap[A, B](implicit arg0: DeriveGen[A], arg1: DeriveGen[B]): DeriveGen[Map[A, B]]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenShort: DeriveGen[Short]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenString: DeriveGen[String]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenURI: DeriveGen[URI]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenURL: DeriveGen[URL]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenUUID: DeriveGen[UUID]
- Definition Classes
- DeriveGenInstances
- implicit def deriveGenZioDuration: DeriveGen[Duration]
- Definition Classes
- DeriveGenInstances
- def generateConfig[A](config: config.ConfigDescriptor[A], size: Int = 0)(implicit arg0: DeriveGen[A]): ZStream[Random with Sized with Clock, String, PropertyTree[String, String]]
Generate an almost valid PropertyTree given a
ConfigDescriptor[A]
andDeriveGen[A]
.Generate an almost valid PropertyTree given a
ConfigDescriptor[A]
andDeriveGen[A]
.Note that
DeriveGen[A]
is going to be available only if all the fields inA
(if A is a case class) has an instance of DeriveGen.Most of the zio-config supported types has
DeriveGen
instances are already providedExample:
sealed trait Region @name("ap-southeast") case object ApSouthEast2 extends Region @name("usEast") case object UsEast extends Region final case class Database(port: Int, url: java.net.URL) final case class MyConfig(region: Region, database: Database) val result = generateConfig(descriptor[MyConfig], 2).unsafeRunChunk println(result) // yield Chunk( Record( Map( region -> Leaf(ap-southeast), database -> Record(Map(port -> Leaf(4220), url -> Leaf(https://def)))) ), Record( Map(region -> Leaf(usEast2), database -> Record(Map(port -> Leaf(5572), url -> Leaf(https://abc))))) )
Note that this is based on ConfigDescriptor and not a direct view of a case class/sealed-trait. This is why you get almost a valid Json. If your entire config is statically represented (meaning, no custom transformation especially using transformOrFail or transform, with maximised usage of sealed traits instead of values that are known only at runtime), then the correctness increases in the emitted value. This is because zio-config would know the behaviour of your Config better, if most of its parts are statically represented.
That said, we are yet to support refined types, and might fail to generate values because of absence of
DeriveGen
instance forRefined[A, B]
. However, providing explicit DeriveGen instances in program is a solution.Also note that the uniqueness in emitted random values is not guaranteed. For this reason you can give appropriate
size
value and emit as manyPropertyTree
until all the required scenarios are covered.- Definition Classes
- GenerateConfig
- def generateConfigHoconString[A](config: config.ConfigDescriptor[A], size: Int = 0)(implicit arg0: DeriveGen[A]): ZStream[Random with Sized with Clock, String, String]
Generate an almost valid configuration in HOCON format given a
ConfigDescriptor[A]
andDeriveGen[A]
.Generate an almost valid configuration in HOCON format given a
ConfigDescriptor[A]
andDeriveGen[A]
.Note that
DeriveGen[A]
is going to be available only if all the fields inA
(if A is a case class) has an instance of DeriveGen.Most of the zio-config supported types has
DeriveGen
instances are already providedExample:
sealed trait Region @name("ap-southeast") case object ApSouthEast2 extends Region @name("usEast") case object UsEast extends Region final case class Database(port: Int, url: java.net.URL) final case class MyConfig(region: Region, database: Database) val result = generateConfigHoconString(descriptor[MyConfig], 1).unsafeRunChunk println(result)
// yield
Chunk( database { port="9427" url="file://def" } region=usEast , database { port="180" url="https://def" } region=ap-southeast )
Note that this is based on ConfigDescriptor and not a direct Json/HOCON view of a case class/sealed-trait. This is why you get almost a valid Json. If your entire config is statically represented (meaning, no custom transformation especially using transformOrFail or transform, with maximised usage of sealed traits instead of values that are known only at runtime), then the correctness increases in the emitted value. This is because zio-config would know the behaviour of your Config better, if most of its parts are statically represented.
That said, we are yet to support refined types, and might fail to generate values because of absence of
DeriveGen
instance forRefined[A, B]
. However, providing explicit DeriveGen instances in program is a solution.Also note that the uniqueness in emitted random values is not guaranteed. For this reason you can give appropriate
size
value and emit as manyPropertyTree
until all the required scenarios are covered.- Definition Classes
- GenerateConfig
- def generateConfigJson[A](config: config.ConfigDescriptor[A], size: Int = 0)(implicit arg0: DeriveGen[A]): ZStream[Random with Sized with Clock, String, String]
Generate an almost valid configuration in Json format given a
ConfigDescriptor[A]
andDeriveGen[A]
.Generate an almost valid configuration in Json format given a
ConfigDescriptor[A]
andDeriveGen[A]
.Note that
DeriveGen[A]
is going to be available only if all the fields inA
(if A is a case class) has an instance of DeriveGen.Most of the zio-config supported types has
DeriveGen
instances are already providedExample:
sealed trait Region @name("ap-southeast") case object ApSouthEast2 extends Region @name("usEast") case object UsEast extends Region final case class Database(port: Int, url: java.net.URL) final case class MyConfig(region: Region, database: Database) val result = generateConfigJson(descriptor[MyConfig], 1).unsafeRunChunk println(result)
// yield
Chunk({ "database" : { "port" : "7625", "url" : "http://abc" }, "region" : "usEast" } ,{ "database" : { "port" : "6904", "url" : "https://abc" }, "region" : "ap-southeast" } )
Note that this is based on the ConfigDescriptor and not a direct Json view of a case class/sealed-trait. This is why you get almost a valid Json. If your entire config is statically represented (meaning, no custom transformation especially using transformOrFail or transform, with maximised usage of sealed traits instead of values that are known only at runtime), then the correctness increases in the emitted value. This is because zio-config would know the behaviour of your Config better, if most of its parts are statically represented.
That said, we are yet to support refined types, and might fail to generate values because of absence of
DeriveGen
instance forRefined[A, B]
. However, providing explicit DeriveGen instances in program is a solution.Also note that the uniqueness in emitted random values is not guaranteed. For this reason you can give appropriate
size
value and emit as manyPropertyTree
until all the required scenarios are covered.- Definition Classes
- GenerateConfig
- def generateConfigMap[A](config: config.ConfigDescriptor[A], size: Int, keyDelimiter: String = ".")(implicit arg0: DeriveGen[A]): ZStream[Random with Sized with Clock, String, Map[String, ::[String]]]
Generate an almost valid configuration in Map format given a
ConfigDescriptor[A]
andDeriveGen[A]
.Generate an almost valid configuration in Map format given a
ConfigDescriptor[A]
andDeriveGen[A]
.Note that
DeriveGen[A]
is going to be available only if all the fields inA
(if A is a case class) has an instance of DeriveGen.Most of the zio-config supported types has
DeriveGen
instances are already providedExample:
sealed trait Region @name("ap-southeast") case object ApSouthEast2 extends Region @name("usEast") case object UsEast extends Region final case class Database(port: Int, url: java.net.URL) final case class MyConfig(region: Region, database: Database) val result = generateConfigMap(descriptor[MyConfig], 1).unsafeRunChunk println(result)
// yields
Chunk( Map( region -> List(ap-southeast), database.port -> List(7627), database.url -> List(https://def) ), Map( region -> List(usEast), database.port -> List(4119), database.url -> List(file://abc)))
Note that this is based on ConfigDescriptor and not a direct Json/HOCON view of a case class/sealed-trait. This is why you get almost a valid Json. If your entire config is statically represented (meaning, no custom transformation especially using transformOrFail or transform, with maximised usage of sealed traits instead of values that are known only at runtime), then the correctness increases in the emitted value. This is because zio-config would know the behaviour of your Config better, if most of its parts are statically represented.
That said, we are yet to support refined types, and might fail to generate values because of absence of
DeriveGen
instance forRefined[A, B]
. However, providing explicit DeriveGen instances in program is a solution.Also note that the uniqueness in emitted random values is not guaranteed. For this reason you can give appropriate
size
value and emit as manyPropertyTree
until all the required scenarios are covered.- Definition Classes
- GenerateConfig
- object GenerateConfig extends GenerateConfig