Pekko

play.api.libs.concurrent.Pekko
object Pekko

Helper to access the application defined Pekko Actor system.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Pekko.type

Members list

Value members

Concrete methods

def bindingOf[T <: Actor : ClassTag](name: String, props: Props => Props): Binding[ActorRef]

Create a binding for an actor implemented by the given class, with the given name.

Create a binding for an actor implemented by the given class, with the given name.

This will instantiate the actor using Play's injector, allowing it to be dependency injected itself. The returned binding will provide the ActorRef for the actor, qualified with the given name, allowing it to be injected into other components.

Example usage from a Play module:

def bindings = Seq(
 Pekko.bindingOf[MyActor]("myActor"),
 ...
)

Then to use the above actor in your application, add a qualified injected dependency, like so:

 class MyController @Inject() (@Named("myActor") myActor: ActorRef,
    val controllerComponents: ControllerComponents) extends BaseController {
   ...
 }

Type parameters

T

The class that implements the actor.

Value parameters

name

The name of the actor.

props

A function to provide props for the actor. The props passed in will just describe how to create the actor, this function can be used to provide additional configuration such as router and dispatcher configuration.

Attributes

Returns

A binding for the actor.

def providerOf[T <: Actor : ClassTag](name: String, props: Props => Props): Provider[ActorRef]

Create a provider for an actor implemented by the given class, with the given name.

Create a provider for an actor implemented by the given class, with the given name.

This will instantiate the actor using Play's injector, allowing it to be dependency injected itself. The returned provider will provide the ActorRef for the actor, allowing it to be injected into other components.

Typically, you will want to use this in combination with a named qualifier, so that multiple ActorRefs can be bound, and the scope should be set to singleton or eager singleton. *

Type parameters

T

The class that implements the actor.

Value parameters

name

The name of the actor.

props

A function to provide props for the actor. The props passed in will just describe how to create the actor, this function can be used to provide additional configuration such as router and dispatcher configuration.

Attributes

Returns

A provider for the actor.