Config
Entry point for loading typed configuration from a ConfigSource.
Attributes
- Source
- Config.scala
- Graph
-
- Supertypes
- Self type
-
Config.type
Members list
Value members
Concrete methods
Decode a value of type A from source using the implicit Schema[A].
Decode a value of type A from source using the implicit Schema[A].
Typical usage in Scala 3 derives both Schema and Unscoped directly on the case class and then loads from a ConfigSource:
import zio.blocks.scope.Unscoped
final case class Db(host: String, port: Int) derives Schema, Unscoped
val result = Config.load[Db](
ConfigSource.fromMap(Map("host" -> "localhost", "port" -> "5432"))
)
This method derives a fresh ConfigDecoder for each call. If you load the same type repeatedly (for example during reloads), derive the decoder once with ConfigDecoder.derive[A] and reuse it directly.
Returns all accumulated ConfigErrors instead of failing fast.
Attributes
- Source
- Config.scala
Decode a value of type A from source using an explicit ConfigDecoderDeriver and the implicit Schema[A].
Decode a value of type A from source using an explicit ConfigDecoderDeriver and the implicit Schema[A].
Attributes
- Source
- Config.scala
Load a value of type A from the given source, or throw with a formatted error report.
Load a value of type A from the given source, or throw with a formatted error report.
Requires an implicit Schema[A]:
import zio.blocks.scope.Unscoped
final case class Db(host: String, port: Int) derives Schema, Unscoped
val db = Config.loadOrThrow[Db](
ConfigSource.fromMap(Map("host" -> "localhost", "port" -> "5432"))
)
Throws ConfigLoadException when decoding fails.
Attributes
- Source
- Config.scala
Load a value of type A together with provenance information for each resolved key.
Load a value of type A together with provenance information for each resolved key.
Requires an implicit Schema[A] and returns a ProvenanceMap[A] so callers can inspect where each resolved field came from:
import zio.blocks.scope.Unscoped
final case class Db(host: String, port: Int) derives Schema, Unscoped
val loaded = Config.loadWithProvenance[Db](
ConfigSource.fromMap(Map("host" -> "localhost", "port" -> "5432"), "env")
)
val hostSource = loaded.map(_.provenanceOf("host"))
Attributes
- Source
- Config.scala
Create a shared config wire that decodes A from an injected ConfigSource.
Create a shared config wire that decodes A from an injected ConfigSource.
Attributes
- Source
- Config.scala
Create a shared config wire that decodes A from an injected ConfigSource under the specified prefix.
Create a shared config wire that decodes A from an injected ConfigSource under the specified prefix.
Attributes
- Source
- Config.scala