Package io.dapr.actors.runtime
Class ActorRuntime
java.lang.Object
io.dapr.actors.runtime.ActorRuntime
public class ActorRuntime
extends java.lang.Object
Contains methods to register actor types. Registering the types allows the
runtime to create instances of the actor.
-
Method Summary
Modifier and Type Method Description reactor.core.publisher.Mono<java.lang.Void>
deactivate(java.lang.String actorTypeName, java.lang.String actorId)
Deactivates an actor for an actor type with given actor id.ActorRuntimeConfig
getConfig()
Gets the Actor configuration for this runtime.static ActorRuntime
getInstance()
Returns an ActorRuntime object.reactor.core.publisher.Mono<byte[]>
invoke(java.lang.String actorTypeName, java.lang.String actorId, java.lang.String actorMethodName, byte[] payload)
Invokes the specified method for the actor, this is mainly used for cross language invocation.reactor.core.publisher.Mono<java.lang.Void>
invokeReminder(java.lang.String actorTypeName, java.lang.String actorId, java.lang.String reminderName, byte[] params)
Fires a reminder for the Actor.reactor.core.publisher.Mono<java.lang.Void>
invokeTimer(java.lang.String actorTypeName, java.lang.String actorId, java.lang.String timerName)
Fires a timer for the Actor.<T extends AbstractActor>
voidregisterActor(java.lang.Class<T> clazz)
Registers an actor with the runtime, usingDefaultObjectSerializer
andDefaultActorFactory
.<T extends AbstractActor>
voidregisterActor(java.lang.Class<T> clazz, ActorFactory<T> actorFactory)
Registers an actor with the runtime, usingDefaultObjectSerializer
.<T extends AbstractActor>
voidregisterActor(java.lang.Class<T> clazz, ActorFactory<T> actorFactory, DaprObjectSerializer objectSerializer, DaprObjectSerializer stateSerializer)
Registers an actor with the runtime.<T extends AbstractActor>
voidregisterActor(java.lang.Class<T> clazz, DaprObjectSerializer objectSerializer, DaprObjectSerializer stateSerializer)
Registers an actor with the runtime.byte[]
serializeConfig()
Gets the Actor configuration for this runtime.
-
Method Details
-
getInstance
Returns an ActorRuntime object.- Returns:
- An ActorRuntime object.
-
getConfig
Gets the Actor configuration for this runtime.- Returns:
- Actor configuration.
-
serializeConfig
public byte[] serializeConfig() throws java.io.IOExceptionGets the Actor configuration for this runtime.- Returns:
- Actor configuration serialized.
- Throws:
java.io.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
public <T extends AbstractActor> void registerActor(java.lang.Class<T> clazz, ActorFactory<T> actorFactory)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(java.lang.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(java.lang.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<java.lang.Void> deactivate(java.lang.String actorTypeName, java.lang.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(java.lang.String actorTypeName, java.lang.String actorId, java.lang.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<java.lang.Void> invokeReminder(java.lang.String actorTypeName, java.lang.String actorId, java.lang.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<java.lang.Void> invokeTimer(java.lang.String actorTypeName, java.lang.String actorId, java.lang.String timerName)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.- Returns:
- Async void task.
-