Skip to content

Instantly share code, notes, and snippets.

@jchapuis
Created May 10, 2020 20:06
Show Gist options
  • Save jchapuis/be56633f26a9856c022b3fdf6a051388 to your computer and use it in GitHub Desktop.
Save jchapuis/be56633f26a9856c022b3fdf6a051388 to your computer and use it in GitHub Desktop.
Markdium-Orchestrating startup and shutdown in Scala
def stopService(service: Service): Task[Either[ServiceStopError, Service]] =
Task.deferFuture {
service.triggerStop()
service.stopped.map(_.map(_ => service))
}.timeout(duration).onErrorRecover {
case _: TimeoutException => ServiceStopTimeoutError(service, duration).asLeft
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment