Skip to content

Instantly share code, notes, and snippets.

@matfournier
Created December 15, 2019 01:21
Show Gist options
  • Save matfournier/26f75468dd425115412ecaffe8a067ae to your computer and use it in GitHub Desktop.
Save matfournier/26f75468dd425115412ecaffe8a067ae to your computer and use it in GitHub Desktop.
zioEnv help
// a NoOpLogger of zio-logging for a logging effect
trait NoOpLogger extends Logging[String] {
def logging: Logging.Service[Any, String] = new Logging.Service[Any, String] {
override def trace(message: => String): ZIO[Any, Nothing, Unit] = ZIO.unit
override def debug(message: => String): ZIO[Any, Nothing, Unit] = ZIO.unit
override def info(message: => String): ZIO[Any, Nothing, Unit] = ZIO.unit
override def warning(message: => String): ZIO[Any, Nothing, Unit] = ZIO.unit
override def error(message: => String): ZIO[Any, Nothing, Unit] = ZIO.unit
override def error(message: => String, cause: Cause[Any]): ZIO[Any, Nothing, Unit] = ZIO.unit
}
}
object NoOpLogger extends NoOpLogger
// some statsD effect w/ a NoOp implementation
trait Statsd { def statsd: Statsd.Service }
object Statsd {
trait Service {
def emit(key: String, value: Int): UIO[Unit]
}
trait NoOp extends Statsd.Service {
def emit(key: String, value: Int): UIO[Unit] = UIO.unit
}
object NoOp extends NoOp
}
// assuming I hav some val doStuff: ZIO[Logging[String] with Statsd, Throwable, A] = { .. } how do I
// construct the env itself to provide?
val env: Logging[String] with Statsd = ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment