Skip to content

Commit

Permalink
Update message handler supervisor to watch children (#11630)
Browse files Browse the repository at this point in the history
close #11248

Changelog:
- update: bind message handler supervisor lifetime to the message handler lifetime
  • Loading branch information
4e6 authored Nov 22, 2024
1 parent 2b9ed57 commit e5a65a2
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import akka.actor.{
OneForOneStrategy,
Props,
Stash,
SupervisorStrategy
SupervisorStrategy,
Terminated
}
import com.typesafe.scalalogging.LazyLogging

Expand Down Expand Up @@ -59,6 +60,7 @@ final class MessageHandlerSupervisor(
Props(new MessageHandler(protocolFactory, clientActor)),
s"message-handler-$clientId"
)
context.watch(messageHandler)
clientActor ! JsonRpcServer.WebConnect(messageHandler, port)
context.become(initialized(messageHandler))
unstashAll()
Expand All @@ -67,8 +69,11 @@ final class MessageHandlerSupervisor(
stash()
}

private def initialized(messageHandler: ActorRef): Receive = { case message =>
messageHandler.forward(message)
private def initialized(messageHandler: ActorRef): Receive = {
case Terminated(`messageHandler`) =>
context.stop(self)
case message =>
messageHandler.forward(message)
}
}

Expand Down

0 comments on commit e5a65a2

Please sign in to comment.