play.api.libs.concurrent
Members list
Type members
Classlikes
Facilitates runtime dependency injection of "functional programming"-style actor behaviors.
Facilitates runtime dependency injection of "functional programming"-style actor behaviors.
- Mix this trait into the
object
defining the actor message(s) and behavior(s); - Define the
Message
type with actor message class; - Annotate with Provides the "create" method that returns the (possibly just initial) Behavior of the actor;
- Use the
bindTypedActor
in AkkaGuiceSupport, passing theobject
as the actor module.
For example:
object ConfiguredActor extends ActorModule {
type Message = GetConfig
final case class GetConfig(replyTo: ActorRef[String])
@Provides def apply(configuration: Configuration): Behavior[GetConfig] = {
// TODO: Define ConfiguredActor's behavior using the injected configuration.
Behaviors.empty
}
}
final class AppModule extends AbstractModule with AkkaGuiceSupport {
override def configure() = {
bindTypedActor(classOf[ConfiguredActor], "configured-actor")
}
}
Message
is a type member rather than a type parameter is because you can't define, using the example above, GetConfig
inside the object and also have the object extend ActorModule[ConfiguredActor.GetConfig]
.
Attributes
- See also
- Companion
- object
- Supertypes
-
class AbstractModuletrait Moduleclass Objecttrait Matchableclass Any
The companion object to hold ActorModule's ActorModule.Aux type alias.
The companion object to hold ActorModule's ActorModule.Aux type alias.
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ActorModule.type
Support for binding actors with Guice.
Support for binding actors with Guice.
Mix this trait in with a Guice AbstractModule to get convenient support for binding actors. For example:
class MyModule extends AbstractModule with AkkaGuiceSupport {
def configure = {
bindActor[MyActor]("myActor")
bindTypedActor(HelloActor(), "hello-actor")
}
}
Then to use the above actor in your application, add a qualified injected dependency, like so:
class MyController @Inject() (
@Named("myActor") myActor: ActorRef,
helloActor: ActorRef[HelloActor.SayHello],
val controllerComponents: ControllerComponents,
) extends BaseController {
...
}
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
AbstractModule
A singleton Provider of the typed ActorRef[T]
resulting from spawning an actor with the Behavior[T]
in dependency scope and the given name, in the ActorSystem in dependency scope.
A singleton Provider of the typed ActorRef[T]
resulting from spawning an actor with the Behavior[T]
in dependency scope and the given name, in the ActorSystem in dependency scope.
Type parameters
- T
-
The class of the messages the typed actor can handle.
Value parameters
- name
-
the name to use when spawning the typed actor.
Attributes
- Supertypes