Skip to content

Commit 83f09fa

Browse files
authored
Prevent spurious logs and double timeout in broadcastDiscard (#115)
1 parent 1529037 commit 83f09fa

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,8 @@ class Sharding private (
348348
case MessengerTimeout.Timeout(duration) => Some(duration)
349349
}
350350

351-
def broadcastDiscard(topic: String)(msg: Msg): UIO[Unit] = {
352-
val send = sendMessage(topic, msg, None)
353-
timeout.fold(send.unit)(t => send.timeout(t).unit)
354-
}
351+
def broadcastDiscard(topic: String)(msg: Msg): UIO[Unit] =
352+
sendMessage(topic, msg, None).unit
355353

356354
def broadcast[Res](topic: String)(msg: Replier[Res] => Msg): UIO[Map[PodAddress, Try[Res]]] =
357355
Random.nextUUID.flatMap { uuid =>
@@ -375,7 +373,9 @@ class Sharding private (
375373

376374
val send = trySend.flatMap {
377375
case Some(value) => ZIO.succeed(value)
378-
case None => ZIO.fail(new Exception(s"Send returned nothing, topic=$topic"))
376+
case None =>
377+
if (replyId.isDefined) ZIO.fail(new Exception(s"Send returned nothing, topic=$topic"))
378+
else ZIO.succeed(null.asInstanceOf[Res])
379379
}
380380
timeout
381381
.fold(send)(t => send.timeoutFail(new Exception(s"Send timed out, topic=$topic"))(t))

0 commit comments

Comments
 (0)