Last active
December 10, 2019 14:59
-
-
Save lforite/47bb31e9cb29c54ca8da71f6da4ff7b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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