All checks were successful
/ Build and Release Library (push) Successful in 1m29s
Reviewed-on: #1
28 lines
700 B
Scala
28 lines
700 B
Scala
package gs.config.v0.source
|
|
|
|
import cats.Applicative
|
|
import gs.config.v0.ConfigKey
|
|
import java.util.UUID
|
|
|
|
/** In-memory implementation based on an immutable map.
|
|
*
|
|
* The raw value of the [[ConfigName]] is used for lookups (`toRawString()`).
|
|
*
|
|
* @param configs
|
|
* The configurations to provide.
|
|
*/
|
|
final class MemoryConfigSource[F[_]: Applicative](
|
|
private val configs: Map[String, String]
|
|
) extends ConfigSource[F]:
|
|
val id: UUID = UUID.randomUUID()
|
|
|
|
/** @inheritDocs
|
|
*/
|
|
override def getValue(
|
|
key: ConfigKey[?]
|
|
): F[Option[String]] =
|
|
Applicative[F].pure(configs.get(key.name.unwrap()))
|
|
|
|
/** @inheritDocs
|
|
*/
|
|
override lazy val name: String = s"in-memory-$id"
|