trait ActorModule extends AbstractModule

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(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()
Source
ActorModule.scala
See also

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

Linear Supertypes
AbstractModule, Module, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ActorModule
  2. AbstractModule
  3. Module
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. abstract type Message

Value Members

  1. final def configure(builder: Binder): Unit
    Definition Classes
    AbstractModule → Module