Created
February 14, 2021 08:48
-
-
Save vigneshwaranr/36b42dc9460cecc33142aa0d52ef4b95 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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) | |
_ = Future(badLibrary.executeOperation())(heavyJobEC) // run entirely in its own separate EC | |
} yield response | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment