Skip to content

Instantly share code, notes, and snippets.

@vigneshwaranr
Created February 14, 2021 08:37
Show Gist options
  • Save vigneshwaranr/d8a88a462d14082eb832ff5b58af2929 to your computer and use it in GitHub Desktop.
Save vigneshwaranr/d8a88a462d14082eb832ff5b58af2929 to your computer and use it in GitHub Desktop.
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.{ExecutionContext, Future}
class API(cacheService: CacheService, processor: Processor) {
def process(request: Request): Future[Response] = {
for {
dedupedRequest <- cacheService.isDuplicateRequest(request)
response <- processor.process(dedupedRequest)
_ = cacheService.setCacheForDeduplication(dedupedRequest) // now unplugged from the flow
_ = badLibrary.executeOperation() // also unplugged.. or is it? ;)
} yield response
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment