vlovgr on ce3
WIP (compare)
vlovgr on gh-pages
Deploy website Deploy website … (compare)
vlovgr on ce3
Update sbt-mdoc to 2.2.13 Merge pull request #410 from sc… Update cats-effect, cats-effect… and 10 more (compare)
vlovgr on master
Update kind-projector to 0.11.2 Change to use kind-projector * … Merge pull request #412 from sc… (compare)
vlovgr on gh-pages
Deploy website Deploy website … (compare)
vlovgr on master
Update cats-effect, cats-effect… Merge pull request #411 from sc… (compare)
vlovgr on gh-pages
Deploy website Deploy website … (compare)
mergify[bot] on master
Update sbt-ci-release to 1.5.5 Merge pull request #414 from sc… (compare)
vlovgr on gh-pages
Deploy website Deploy website … (compare)
mergify[bot] on master
Update refined to 0.9.19 Merge pull request #413 from sc… (compare)
flatMap
might be an issue...
FlatMap[ConfigValue]
already
final def eval[F[_], A](value: F[ConfigValue[A]])(implicit F: Effect[F]): ConfigValue[A]
might be my workaround.
flatMap
cannot be expressed in a stack-safe manner, and also pure
would not be what you expect, as discussed here: https://gitter.im/vlovgr/ciris?at=5dc6643b5eb2e813dbf0f3b0
ConfigValue.async
if you really need something like Async[ConfigValue]
.
ConfigValue[+F[_], A]
, similar to fs2's Stream
.
Hey folks, is this a useful addition to ciris? Does it already exist but I've overlooked it?
https://github.com/dimitarg/ciris-propsfile/blob/master/src/main/scala/ciris/propsfile/package.scala
example usage at
Let me know if it doesn't exist and is useful and you'd like such a PR
I prefer to use env
usually but had to switch a project to files because of security considerations, this little bit came out of that
I have a value I need to encode differently based on some config. lets keep it simple
case class MyValue(value: String)
case class MyValueEncodingPrefix(value: String)
is there a nice way of doing this with Ciris? ConfigValue
seems to need an Async to load and Circe's Encoder isn't async.
ConfigValue
only describes how to load a configuration. Normally you would load the configuration first as a separate step, then use that configuration to do something else, e.g. encode a value. In that sense, ConfigValue
and Encoder
are separate.
Hi,
trying to understand the circe example, but feeling slightly confused:
import ciris.circe._
import ciris.ConfigDecoder
import io.circe.{Decoder, Json}
ConfigDecoder[String, Json]
// res0: ConfigDecoder[String, Json] = ConfigDecoder$2047428395
case class SerialNumber(value: String)
object SerialNumber {
implicit val serialNumberDecoder: Decoder[SerialNumber] =
Decoder[String].map(apply)
}
circeConfigDecoder[SerialNumber]("SerialNumber")
My understanding would be that, the circe module would be to parse a string that is actually a json e.g. a json Array, passed as an env variable. However in the example above, i do not see how circe is actually used. I do not see where the json is being produced. Can someone help me understand the example or how the module is supposed to be used. Let say i would like to pass as env variable an array of value, what would be the way to go ?
@Maatary your best bet is probably to put the config decoder as an implicit in the companion object.
case class SerialNumber(value: String)
object SerialNumber {
implicit val serialNumberDecoder: Decoder[SerialNumber] =
Decoder[String].map(apply)
implicit val serialNumberConfigDecoder: ConfigDecoder[String, SerialNumber] =
circeConfigDecoder("SerialNumber")
}
and then you can e.g. do env("SERIAL").as[SerialNumber]
. If you want to decode an array instead, you only need to change the decoder.
import ciris.circe._
import ciris.{ConfigDecoder, env}
import io.circe.{Decoder, Json}
ConfigDecoder[String, Json]
case class SerialNumber(value: String)
object SerialNumber {
implicit val serialNumberDecoder: Decoder[SerialNumber] =
Decoder[String].map(apply)
}
case class SerialNumbers(toList: List[SerialNumber])
object SerialNumbers {
implicit val serialNumbersDecoder: Decoder[SerialNumbers] =
Decoder[List[SerialNumber]].map(apply)
implicit val serialNumbersConfigDecoder: ConfigDecoder[String, SerialNumbers] =
circeConfigDecoder("SerialNumbers")
}
env("SERIAL_NUMBERS").as[SerialNumbers]