Created
May 10, 2020 20:06
-
-
Save jchapuis/7006c57e06b8b3163b71e7a43a70de7a 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
class ClusterUpAndServiceBoundCheck(system: ActorSystem) extends (() => Future[Boolean]) { | |
private val cluster = Cluster(system) | |
discard { | |
CoordinatedShutdown(system).serviceUnbind( | |
() => | |
Future.successful { | |
serviceUnbound.set(true) | |
Done | |
}, | |
"service-unbound-check" | |
) | |
} | |
private val serviceUnbound = new AtomicBoolean(false) | |
override def apply(): Future[Boolean] = | |
Future.successful(cluster.selfMember.status match { | |
case MemberStatus.Up => !serviceUnbound.get() | |
case _ => false | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment