mitrakov

Ciris basic example

Apr 22nd, 2020
820
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import cats.effect.{Async, ContextShift}
  2. import ciris.env
  3. import eu.timepit.refined.types.net.UserPortNumber
  4. import eu.timepit.refined.types.string.NonEmptyString
  5.  
  6. class ConfigLoader {
  7.   import cats.syntax.parallel._
  8.   import cats.instances.int.catsStdShowForInt
  9.   import cats.instances.string.catsStdShowForString
  10.   import ciris.refined.refTypeConfigDecoder
  11.   import eu.timepit.refined.auto.autoRefineV
  12.   import eu.timepit.refined.cats.refTypeShow
  13.  
  14.   private def loadConfig[F[_]: Async: ContextShift]: F[EventsAmqpConfig] = {
  15.     (
  16.       env("AMQP_HOST").as[NonEmptyString].default("localhost"),
  17.       env("AMQP_PORT").as[UserPortNumber].default(5672),
  18.       env("AMQP_USER").as[NonEmptyString].default("guest"),
  19.       env("AMQP_PASSWORD").as[NonEmptyString].default("guest").secret
  20.     ).parMapN(MyCaseClass).load[F]
  21.   }
  22. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×