case class Descriptor[T](desc: config.ConfigDescriptor[T], isObject: Boolean = false) extends Product with Serializable
- Alphabetic
- By Inheritance
- Descriptor
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Descriptor(desc: config.ConfigDescriptor[T], isObject: Boolean = false)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ??(description: String): Descriptor[T]
To add documentation while defining an instance of Descriptor.
To add documentation while defining an instance of Descriptor.
To give an overview of what
Descriptor
:descriptor[MyConfig]
works only if all the types that formsMyConfig
has an instance ofDescriptor
. For almost all the important types, zio-config-magnolia already provides implicit instances forDescriptor
. However, say you have a type ZonedDateTime, for which zio-config hasn't provided instance ofDescriptor
, then it will fail to compile.case class MyConfig(x: ZonedDateTime)
In this case, define a Descriptor for ZonedDateTime using
val descriptorForZonedDateTime: Descriptor[ZonedDateTime] = Descriptor[String].transformOrFail(string => Try(ZonedDateTime.parse(string).toEither.swap.map(_.getMessage).swap, r => Right(r.toString))
With
??
, you can provide documentation as well.That is:
implicit def deriveForZonedDateTime: Descriptor[ZonedDateTime] = descriptorForZonedDateTime ?? "Time in UTC" descriptor[MyConfig] // then works
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def default(value: T): Descriptor[T]
To provide default values while defining an instance of Descriptor.
To provide default values while defining an instance of Descriptor.
To give an overview of what
Descriptor
:descriptor[MyConfig]
works only if all the types that formsMyConfig
has an instance ofDescriptor
. For almost all the important types, zio-config-magnolia already provides implicit instances forDescriptor
. However, say you have a type ZonedDateTime, for which zio-config hasn't provided instance ofDescriptor
, then it will fail to compile.case class MyConfig(x: ZonedDateTime)
In this case, define a Descriptor for ZonedDateTime using
val descriptorForZonedDateTime: Descriptor[ZonedDateTime] = Descriptor[String].transformOrFail(string => Try(ZonedDateTime.parse(string).toEither.swap.map(_.getMessage).swap, r => Right(r.toString))
With
default
, you can provide documentation as well.That is:
implicit def deriveForZonedDateTime: Descriptor[ZonedDateTime] = descriptorForZonedDateTime.default(ZonedDateTime.now()) descriptor[MyConfig] // then works
- val desc: config.ConfigDescriptor[T]
- def describe(description: String): Descriptor[T]
To add documentation while defining an instance of Descriptor.
To add documentation while defining an instance of Descriptor.
To give an overview of what
Descriptor
:descriptor[MyConfig]
works only if all the types that formsMyConfig
has an instance ofDescriptor
. For almost all the important types, zio-config-magnolia already provides implicit instances forDescriptor
. However, say you have a type ZonedDateTime, for which zio-config hasn't provided instance ofDescriptor
, then it will fail to compile.case class MyConfig(x: ZonedDateTime)
In this case, define a Descriptor for ZonedDateTime using
val descriptorForZonedDateTime: Descriptor[ZonedDateTime] = Descriptor[String].transformOrFail(string => Try(ZonedDateTime.parse(string).toEither.swap.map(_.getMessage).swap, r => Right(r.toString))
With
describe
, you can provide documentation as well.That is:
implicit def deriveForZonedDateTime: Descriptor[ZonedDateTime] = descriptorForZonedDateTime describe "Time in UTC" descriptor[MyConfig] // then works
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def from(that: config.ConfigSource): Descriptor[T]
To provide source while defining an instance for descriptor
To provide source while defining an instance for descriptor
To give an overview of what
Descriptor
:descriptor[MyConfig]
works only if all the types that formsMyConfig
has an instance ofDescriptor
. For almost all the important types, zio-config-magnolia already provides implicit instances forDescriptor
. However, say you have a type ZonedDateTime, for which zio-config hasn't provided instance ofDescriptor
, then it will fail to compile.case class MyConfig(x: ZonedDateTime, username: String)
In this case, define a Descriptor for ZonedDateTime using
val descriptorForZonedDateTime: Descriptor[ZonedDateTime] = Descriptor[String].transformOrFail(string => Try(ZonedDateTime.parse(string).toEither.swap.map(_.getMessage).swap, r => Right(r.toString))
With
from
, you can provide documentation as well.That is:
val defaultSource: ConfigSource = ??? implicit def deriveForZonedDateTime: Descriptor[ZonedDateTime] = descriptorForZonedDateTime from defaultSource val envSource: ConfigSource = ??? val result: Either[ReadError[String], MyConfig] = read(descriptor[MyConfig] from envSource)
For ZonedDateTime, it always tries the
defaultSource
first, and then if it fails tries theenvSource
. - final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val isObject: Boolean
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def transform[B](f: (T) => B, g: (B) => T): Descriptor[B]
transform
allows us to define instance ofDescriptor
transform
allows us to define instance ofDescriptor
To give an overview of what
Descriptor
:descriptor[MyConfig]
works only if all the types that formsMyConfig
has an instance ofDescriptor
. For almost all the important types, zio-config-magnolia already provides implicit instances forDescriptor
. However, say you have a type ZonedDateTime, for which zio-config hasn't provided instance ofDescriptor
, then it will fail to compile.case class MyConfig(x: ZonedDateTime)
In this case, define a Descriptor for ZonedDateTime using
implicit val descriptorForZonedDateTime: Descriptor[ZonedDateTime] = Descriptor[String].transform(string => ZonedDateTime.parse(string), _.toString) descriptor[MyConfig] // now works
However, we recommend you using
transformOrFail
, because in the above caseZonedDateTime.parse(string)
may fail and isn't handled anywhere. With transformOrFail, its properly handled and will be part of the error message if zio-config fails to retrieve the config. - def transformOrFail[B](f: (T) => Either[String, B], g: (B) => Either[String, T]): Descriptor[B]
transformOrFail
allows us to define instance ofDescriptor
transformOrFail
allows us to define instance ofDescriptor
To give an overview of what
Descriptor
:descriptor[MyConfig]
works only if all the types that formsMyConfig
has an instance ofDescriptor
. For almost all the important types, zio-config-magnolia already provides implicit instances forDescriptor
. However, say you have a type ZonedDateTime, for which zio-config hasn't provided instance ofDescriptor
, then it will fail to compile.case class MyConfig(x: ZonedDateTime)
In this case, define a Descriptor for ZonedDateTime using
implicit val descriptorForZonedDateTime: Descriptor[ZonedDateTime] = Descriptor[String].transformOrFail(string => Try(ZonedDateTime.parse(string).toEither.swap.map(_.getMessage).swap, r => Right(r.toString)) descriptor[MyConfig] // now works
You can also see the
ZonedDateTime => String
doesn't fail, and we had to lift to Either type usingRight
constructor. Hence it is better off usingtransformOrFailLeft
in this case. - def transformOrFailLeft[B](f: (T) => Either[String, B])(g: (B) => T): Descriptor[B]
transformOrFailLeft
allows us to define instance ofDescriptor
transformOrFailLeft
allows us to define instance ofDescriptor
To give an overview of what
Descriptor
:descriptor[MyConfig]
works only if all the types that formsMyConfig
has an instance ofDescriptor
. For almost all the important types, zio-config-magnolia already provides implicit instances forDescriptor
. However, say you have a type ZonedDateTime, for which zio-config hasn't provided instance ofDescriptor
, then it will fail to compile.case class MyConfig(x: ZonedDateTime)
In this case, define a Descriptor for ZonedDateTime using
implicit val descriptorForZonedDateTime: Descriptor[ZonedDateTime] = Descriptor[String].transformOrFailLeft(string => Try(ZonedDateTime.parse(string).toEither.swap.map(_.getMessage).swap, _.toString) descriptor[MyConfig] // now works
- def transformOrFailRight[E, B](f: (T) => B, g: (B) => Either[String, T]): Descriptor[B]
transformOrFailRight
allows us to define instance ofDescriptor
transformOrFailRight
allows us to define instance ofDescriptor
To give an overview of what
Descriptor
:descriptor[MyConfig]
works only if all the types that formsMyConfig
has an instance ofDescriptor
. For almost all the important types, zio-config-magnolia already provides implicit instances forDescriptor
.However, say you have a type ZonedDateTime, for which zio-config hasn't provided instance of
Descriptor
, then it will fail to compile.case class MyConfig(x: ZonedDateTime)
In this case, define a Descriptor for ZonedDateTime using
implicit val descriptorForZonedDateTime: Descriptor[ZonedDateTime] = Descriptor[String].transformOrFailRight(string => Try(ZonedDateTime.parse(string).toEither.swap.map(_.getMessage).swap, _.toString) descriptor[MyConfig] // now works
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()