diff --git a/example/src/main/resources/logback.xml b/example/src/main/resources/logback.xml
index 34ec309..07ed72b 100644
--- a/example/src/main/resources/logback.xml
+++ b/example/src/main/resources/logback.xml
@@ -8,10 +8,11 @@
+
-
+
\ No newline at end of file
diff --git a/example/src/main/scala/endless/transaction/example/app/pekko/PekkoAccountsApp.scala b/example/src/main/scala/endless/transaction/example/app/pekko/PekkoAccountsApp.scala
index 27f586b..96c5024 100644
--- a/example/src/main/scala/endless/transaction/example/app/pekko/PekkoAccountsApp.scala
+++ b/example/src/main/scala/endless/transaction/example/app/pekko/PekkoAccountsApp.scala
@@ -39,7 +39,7 @@ object PekkoAccountsApp {
private implicit val transferParameters: TransferParameters =
TransferParameters(timeout = 30.seconds)
private implicit val askTimeout: Timeout = Timeout(30.seconds)
- private val terminationTimeout = 30.seconds
+ private val terminationTimeout = 5.seconds
private lazy val pekkoEventAdapter = new EventAdapter[AccountEvent, events.AccountEvent] {
private val eventAdapter = new AccountEventAdapter
override def toJournal(e: AccountEvent): events.AccountEvent = eventAdapter.toJournal(e)
diff --git a/example/src/multi-jvm/scala/endless/transaction/example/StressSuite.scala b/example/src/multi-jvm/scala/endless/transaction/example/StressSuite.scala
index 9ccf5bf..52bf757 100644
--- a/example/src/multi-jvm/scala/endless/transaction/example/StressSuite.scala
+++ b/example/src/multi-jvm/scala/endless/transaction/example/StressSuite.scala
@@ -1,6 +1,6 @@
package endless.transaction.example
-import cats.effect.{IO, Ref}
+import cats.effect.IO
import cats.effect.kernel.Resource
import cats.effect.std.Random
import cats.effect.unsafe.implicits.global
@@ -186,20 +186,19 @@ object Common {
def restartingPassiveNode(httpPort: Port, arteryPort: Port): IO[Unit] =
Slf4jLogger.create[IO].flatMap { logger =>
lazy val restartingNode: IO[Unit] = for {
- checkSuccessful <- Ref.of[IO, Boolean](false)
random <- Random.scalaUtilRandom[IO]
restartPeriod <- random
.betweenInt(minRestartDelaySeconds, maxRestartDelaySeconds)
.map(_.seconds)
- _ <- IO.race(
- passiveNode(httpPort, arteryPort, checkSuccessful)
+ result <- IO.race(
+ passiveNode(httpPort, arteryPort)
.handleErrorWith((error: Throwable) => logger.error(error)("Node hard fail").toResource)
.use_,
- IO.sleep(restartPeriod)
+ IO.sleep(restartPeriod) >> logger.info("Time elapsed, shutting down...")
)
- _ <- checkSuccessful.get.flatMap {
- case true => logger.info("Balance check successful, terminating...")
- case false =>
+ _ <- result match {
+ case Left(_) => logger.info("Balance check successful, terminating...")
+ case Right(_) =>
logger.info("Restarting node...") >> IO.sleep(nodeRestartWaitingTime) >> restartingNode
}
} yield ()
@@ -214,8 +213,7 @@ object Common {
private def passiveNode(
httpPort: Port,
- arteryPort: Port,
- checkSuccessful: Ref[IO, Boolean]
+ arteryPort: Port
): Resource[IO, Unit] =
for {
logger <- Slf4jLogger.create[IO].toResource
@@ -234,7 +232,6 @@ object Common {
accountsCount,
originAmount - transferAmount
).toResource
- _ <- checkSuccessful.set(true).toResource
_ <- logger.info("Shutting down").toResource
} yield ()