A passagem do ActorRef para outros atores é boa ou ruim?
Estou tentando descobrir se meu uso de passar AkkaActorRef
para outros atores não é um anti-padrão.
Eu tenho alguns atores no meu sistema. Alguns têm vida longa (restClientRouter
,publisher
) e alguns morrem depois de terem feito o trabalho (geoActor
) Os atores de vida curta precisam enviar mensagens aos atores de vida longa e, portanto, precisam deActorRef
s.
//router for a bunch of other actors
val restClientRouter = createRouter(context.system)
//publishers messages to an output message queue
val publisher: ActorRef = context.actorOf(Props(new PublisherActor(host, channel)), name = "pub-actor")
//this actor send a message to the restClientRouter and then sends the response
//to the publisher
val geoActor = context.actorOf(Props(new GeoInferenceActor(restClientRouter, publisher)), name = "geo-inference-actor")
Como você pode ver, estou passando os ActorRefs (restClientRouter
epublisher
) ao construtor deGeoInferenceActor
. Está tudo bem ou não? Existe um jeito melhor de fazer isso ?