Class ActorRuntime

java.lang.Object
io.dapr.actors.runtime.ActorRuntime
All Implemented Interfaces:
Closeable, AutoCloseable

public class ActorRuntime extends Object implements Closeable
Contains methods to register actor types. Registering the types allows the runtime to create instances of the actor.
  • Method Details

    • getInstance

      public static ActorRuntime getInstance()
      Returns an ActorRuntime object.
      Returns:
      An ActorRuntime object.
    • getConfig

      public ActorRuntimeConfig getConfig()
      Gets the Actor configuration for this runtime.
      Returns:
      Actor configuration.
    • serializeConfig

      public byte[] serializeConfig() throws IOException
      Gets the Actor configuration for this runtime.
      Returns:
      Actor configuration serialized.
      Throws:
      IOException - If cannot serialize config.
    • registerActor

      public <T extends AbstractActor> void registerActor(Class<T> clazz)
      Registers an actor with the runtime, using DefaultObjectSerializer and DefaultActorFactory. DefaultObjectSerializer is not recommended for production scenarios.
      Type Parameters:
      T - Actor class type.
      Parameters:
      clazz - The type of actor.
    • registerActor

      public <T extends AbstractActor> void registerActor(Class<T> clazz, ActorFactory<T> actorFactory)
      Registers an actor with the runtime, using DefaultObjectSerializer. DefaultObjectSerializer is not recommended for production scenarios.
      Type Parameters:
      T - Actor class type.
      Parameters:
      clazz - The type of actor.
      actorFactory - An optional factory to create actors. This can be used for dependency injection.
    • registerActor

      public <T extends AbstractActor> void registerActor(Class<T> clazz, DaprObjectSerializer objectSerializer, DaprObjectSerializer stateSerializer)
      Registers an actor with the runtime.
      Type Parameters:
      T - Actor class type.
      Parameters:
      clazz - The type of actor.
      objectSerializer - Serializer for Actor's request and response objects.
      stateSerializer - Serializer for Actor's state objects.
    • registerActor

      public <T extends AbstractActor> void registerActor(Class<T> clazz, ActorFactory<T> actorFactory, DaprObjectSerializer objectSerializer, DaprObjectSerializer stateSerializer)
      Registers an actor with the runtime.
      Type Parameters:
      T - Actor class type.
      Parameters:
      clazz - The type of actor.
      actorFactory - An optional factory to create actors. This can be used for dependency injection.
      objectSerializer - Serializer for Actor's request and response objects.
      stateSerializer - Serializer for Actor's state objects.
    • deactivate

      public reactor.core.publisher.Mono<Void> deactivate(String actorTypeName, String actorId)
      Deactivates an actor for an actor type with given actor id.
      Parameters:
      actorTypeName - Actor type name to deactivate the actor for.
      actorId - Actor id for the actor to be deactivated.
      Returns:
      Async void task.
    • invoke

      public reactor.core.publisher.Mono<byte[]> invoke(String actorTypeName, String actorId, String actorMethodName, byte[] payload)
      Invokes the specified method for the actor, this is mainly used for cross language invocation.
      Parameters:
      actorTypeName - Actor type name to invoke the method for.
      actorId - Actor id for the actor for which method will be invoked.
      actorMethodName - Method name on actor type which will be invoked.
      payload - RAW payload for the actor method.
      Returns:
      Response for the actor method.
    • invokeReminder

      public reactor.core.publisher.Mono<Void> invokeReminder(String actorTypeName, String actorId, String reminderName, byte[] params)
      Fires a reminder for the Actor.
      Parameters:
      actorTypeName - Actor type name to invoke the method for.
      actorId - Actor id for the actor for which method will be invoked.
      reminderName - The name of reminder provided during registration.
      params - Params for the reminder.
      Returns:
      Async void task.
    • invokeTimer

      public reactor.core.publisher.Mono<Void> invokeTimer(String actorTypeName, String actorId, String timerName, byte[] params)
      Fires a timer for the Actor.
      Parameters:
      actorTypeName - Actor type name to invoke the method for.
      actorId - Actor id for the actor for which method will be invoked.
      timerName - The name of timer provided during registration.
      params - Params to trigger timer.
      Returns:
      Async void task.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable