Created
May 10, 2020 20:18
-
-
Save jchapuis/75d2bcf9eeb4b8a33ec62a6075c2d8f9 to your computer and use it in GitHub Desktop.
Markdium-Orchestrating startup and shutdown in Scala
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
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