Last active
February 14, 2021 08:14
-
-
Save vigneshwaranr/ce75246f8b9e8a23c057bb5f6d3362e1 to your computer and use it in GitHub Desktop.
Revisions
-
vigneshwaran-raveendran revised this gist
Feb 14, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ class API(cacheService: CacheService, processor: Processor) { for { dedupedRequest <- cacheService.isDuplicateRequest(request) response <- processor.process(dedupedRequest) _ <- cacheService.setCacheForDeduplication(dedupedRequest) // what's wrong here? } yield response } } -
vigneshwaran-raveendran revised this gist
Feb 14, 2021 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,18 @@ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.{ExecutionContext, Future} trait Request trait Response trait CacheService { def isDuplicateRequest(request: Request)(implicit ec: ExecutionContext): Future[Option[Request]] def setCacheForDeduplication(dedupedReq: Option[Request])(implicit ec: ExecutionContext): Future[Boolean] } trait Processor { def process(request: Option[Request])(implicit ec: ExecutionContext): Future[Response] } class API(cacheService: CacheService, processor: Processor) { @@ -19,7 +21,7 @@ class API(cacheService: CacheService, processor: Processor) { for { dedupedRequest <- cacheService.isDuplicateRequest(request) response <- processor.process(dedupedRequest) _ <- cacheService.setCacheForDeduplication(dedupedRequest) } yield response } } -
vigneshwaran-raveendran created this gist
Feb 14, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future trait Request trait Response trait CacheService { def isDuplicateRequest(request: Request): Future[Option[Request]] def setCacheForDeduplication(dedupedReq: Option[Request]): Future[Boolean] } trait Processor { def process(request: Option[Request]): Future[Response] } class API(cacheService: CacheService, processor: Processor) { def process(request: Request): Future[Response] = { for { dedupedRequest <- cacheService.isDuplicateRequest(request) response <- processor.process(dedupedRequest) _ <- cacheService.setCacheForDeduplication(dedupedRequest) // what's wrong here? } yield response } }