Spawn Global Actors Synchronously

Hi,

I’d like certain actors to be globally available in my application. My specific use-case is a “status actor” that monitors the overall health of the application, who any actor should be able to report to.

I want this global actor(s) to be accessible without much code overhead - no asynchronous request-response patterns to obtain the ActorRef. Think of adding logging capabilities using a trait.

The best approach I have found so far seems to be to write an Extension that creates the ActorRef synchronously using systemActorOf, and then makes this ActorRef accessible for all.

Are there any obvious caveats/problems with using systemActorOf and/or is there a better approach?

Cheers

As long as “global” only means global for a single actor system and not a cluster an extension is a good choice, remember that the thread safety of extensions is up to you as a developer (as opposed to taken care of by the actor model or streams in the rest of your code).

For a distributed app Cluster Singleton or Distributed Data would be options to look into for storing status for the entire app.

1 Like