Skip to content

Commit ab599b1

Browse files
authored
Make sure terminateAllEntities doesn't get interrupted (#106)
1 parent 390605f commit ab599b1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

entities/src/main/scala/com/devsisters/shardcake/Sharding.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ class Sharding private (
4747
isShuttingDownRef.set(true) *>
4848
entityStates.get.flatMap(
4949
ZIO.foreachDiscard(_) { case (name, entity) =>
50-
entity.entityManager.terminateAllEntities.catchAllCause(
51-
ZIO.logErrorCause(s"Error during stop of entity $name", _)
52-
)
50+
entity.entityManager.terminateAllEntities.forkDaemon // run in a daemon fiber to make sure it doesn't get interrupted
51+
.flatMap(_.join)
52+
.catchAllCause(ZIO.logErrorCause(s"Error during stop of entity $name", _))
5353
}
5454
) *>
5555
ZIO.logDebug(s"Unregistering pod $address to Shard Manager") *>

0 commit comments

Comments
 (0)