Skip to content

Instantly share code, notes, and snippets.

@jchapuis
Created May 10, 2020 20:18
Show Gist options
  • Save jchapuis/5f52d3317b9e7d3db97a7ea86176871b to your computer and use it in GitHub Desktop.
Save jchapuis/5f52d3317b9e7d3db97a7ea86176871b to your computer and use it in GitHub Desktop.
Markdium-Orchestrating startup and shutdown in Scala
(for {
_ <- Task.fromFuture(stopTriggered)
results <- startResults
stopResults <- Observable
.fromIterable(results.startedServices.reverse)
.mapEval(stopService)
.foldLeftL(List.empty[Either[ServiceStopError, Service]])(
(stopResults, stopResult) => stopResults :+ stopResult
)
} yield {
stopResults
}): Task[List[Either[ServiceStopError, Service]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment