Created
May 10, 2020 20:18
-
-
Save jchapuis/0c7a940582842b85e926283a86721663 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