Package io.dapr.actors.runtime
Class ActorRuntime
java.lang.Object
io.dapr.actors.runtime.ActorRuntime
- All Implemented Interfaces:
Closeable
,AutoCloseable
Contains methods to register actor types. Registering the types allows the
runtime to create instances of the actor.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
reactor.core.publisher.Mono<Void>
deactivate
(String actorTypeName, String actorId) Deactivates an actor for an actor type with given actor id.Gets the Actor configuration for this runtime.static ActorRuntime
Returns an ActorRuntime object.static ActorRuntime
getInstance
(Properties properties) Returns an ActorRuntime object.reactor.core.publisher.Mono<byte[]>
Invokes the specified method for the actor, this is mainly used for cross language invocation.reactor.core.publisher.Mono<Void>
invokeReminder
(String actorTypeName, String actorId, String reminderName, byte[] params) Fires a reminder for the Actor.reactor.core.publisher.Mono<Void>
invokeTimer
(String actorTypeName, String actorId, String timerName, byte[] params) Fires a timer for the Actor.<T extends AbstractActor>
voidregisterActor
(Class<T> clazz) Registers an actor with the runtime, usingDefaultObjectSerializer
andDefaultActorFactory
.<T extends AbstractActor>
voidregisterActor
(Class<T> clazz, ActorFactory<T> actorFactory) Registers an actor with the runtime, usingDefaultObjectSerializer
.<T extends AbstractActor>
voidregisterActor
(Class<T> clazz, ActorFactory<T> actorFactory, DaprObjectSerializer objectSerializer, DaprObjectSerializer stateSerializer) Registers an actor with the runtime.<T extends AbstractActor>
voidregisterActor
(Class<T> clazz, DaprObjectSerializer objectSerializer, DaprObjectSerializer stateSerializer) Registers an actor with the runtime.byte[]
Gets the Actor configuration for this runtime.
-
Method Details
-
getInstance
Returns an ActorRuntime object.- Returns:
- An ActorRuntime object.
-
getInstance
Returns an ActorRuntime object.- Parameters:
properties
- Properties to be used for the runtime.- Returns:
- An ActorRuntime object.
-
getConfig
Gets the Actor configuration for this runtime.- Returns:
- Actor configuration.
-
serializeConfig
Gets the Actor configuration for this runtime.- Returns:
- Actor configuration serialized.
- Throws:
IOException
- If cannot serialize config.
-
registerActor
Registers an actor with the runtime, usingDefaultObjectSerializer
andDefaultActorFactory
.DefaultObjectSerializer
is not recommended for production scenarios.- Type Parameters:
T
- Actor class type.- Parameters:
clazz
- The type of actor.
-
registerActor
Registers an actor with the runtime, usingDefaultObjectSerializer
.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
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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-