Skip to content

Instantly share code, notes, and snippets.

@jchapuis
Created May 10, 2020 20:18
Show Gist options
  • Save jchapuis/ed73139e5620ff1dbe59208d3db11425 to your computer and use it in GitHub Desktop.
Save jchapuis/ed73139e5620ff1dbe59208d3db11425 to your computer and use it in GitHub Desktop.
Markdium-Orchestrating startup and shutdown in Scala
"notify stopped with error in case of service stop timeout" in {
implicit val scheduler = TestScheduler()
val serviceA = Service.withName("A").withStopper(() => Future.never).build
val serviceB = Service.withName("B").withStopper(() => Future.successful(())).build
Given("a started composite with finite stopped timeout")
implicit val stoppedTimeout = FiniteStoppedTimeout(30 seconds)
val composite = new CompositeService(serviceA, serviceB)
composite.start()
scheduler.tick(1 second)
When("stopping the composite")
composite.triggerStop()
Then("composite eventually notifies stopped with errors")
scheduler.tick(31 seconds) // this simulates 31 seconds elapsing
composite.stopped.futureValue shouldBe left
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment