Skip to content

Instantly share code, notes, and snippets.

@remeniuk
Created November 23, 2010 21:13
Show Gist options
  • Save remeniuk/712544 to your computer and use it in GitHub Desktop.
Save remeniuk/712544 to your computer and use it in GitHub Desktop.
/**
* Publishes all local actors as remote references to the linked registry
* when the registry link is added
*/
trait StartupActorRefsDistribution extends RegistryActor{
/**
* Adds link to remote registry, and register all local actors at there
*/
protected override def addRegistryLink(link: RegistryLink) = {
super.addRegistryLink(link)
registerActorsAt(linkedRegistries.get(link))
}
/**
* Registers all local actors at the remote node
*/
private def registerActorsAt(remoteRegistry: ActorRef) = {
ActorRegistry.filter(actor =>
actor.id == REGISTRY_ACTOR && isActorLocal(actor))
.foreach{actor => remoteRegistry ! RegisterActor(actor)}
remoteRegistry
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment