Packages

p

play.api.libs

concurrent

package concurrent

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Type Members

  1. trait ActorModule extends AbstractModule

    Facilitates runtime dependency injection of "functional programming"-style actor behaviors.

    Facilitates runtime dependency injection of "functional programming"-style actor behaviors.

    1. Mix this trait into the object defining the actor message(s) and behavior(s); 2. Define the Message type with actor message class; 3. Annotate with Provides the "create" method that returns the (possibly just initial) Behavior of the actor; 4. Use the bindTypedActor in PekkoGuiceSupport, passing the object 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 PekkoGuiceSupport {
      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].

    Annotations
    @ApiMayChange()
    See also

    https://pekko.apache.org/docs/pekko/1.0/typed/style-guide.html#functional-versus-object-oriented-style

  2. trait PekkoGuiceSupport extends AnyRef

    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 PekkoGuiceSupport {
      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 {
      ...
    }
  3. final class TypedActorRefProvider[T] extends Provider[ActorRef[T]]

    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.

    T

    The class of the messages the typed actor can handle.

    Annotations
    @Singleton() @ApiMayChange()

Value Members

  1. object ActorModule

    The companion object to hold ActorModule's ActorModule.Aux type alias.

    The companion object to hold ActorModule's ActorModule.Aux type alias.

    Annotations
    @ApiMayChange()

Ungrouped