Skip to content

Instantly share code, notes, and snippets.

@lforite
Last active December 10, 2019 14:59
Show Gist options
  • Save lforite/47bb31e9cb29c54ca8da71f6da4ff7b4 to your computer and use it in GitHub Desktop.
Save lforite/47bb31e9cb29c54ca8da71f6da4ff7b4 to your computer and use it in GitHub Desktop.
trait ServiceA {
def createA(a: EntityA, cid: CorrelationId): IO[_]
}
trait ClientB {
def getB(bId: EntityBID, cid: CorrelationId): IO[_]
}
case class ServiceAImpl(clientB: ClientB) extends ServiceA {
override def createA(a: EntityA, cid: CorrelationId): IO[_] = {
for {
entityB <- clientB.getB(a.idOfB, cid)
processed <- somePrivateBusinessLogic(entityB, cid)
result <- someMoreBusinessLogic(processed, cid)
_ <- logger.info(s"Successfully processed entity ${a.id} ", cid)
} yield result
}
}
trait Logger {
def error(msg: String, t: Throwable, cid: CorrelationId): Unit
def info(msg: String, cid: CorrelationId): Unit = {
underlyingLogger.info(s"[${cid}] $msg")
}
def debug(msg: String, cid: CorrelationId): Unit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment