Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
Obtains the ActorRef to a local actor in this actor system.
Obtains the ActorRef to a local actor in this actor system.
Value parameters
- ClassTag
-
A given instance of a ClassTag for the actor's message type
M
. Used internally to circumvent the JVM's type limitations. - name
-
The unique name of the actor in this actor system.
Attributes
- Returns
-
An
IO
of ActorRef for the given actor name if it exists or a failedIO
otherwise.
Obtains the ActorRef to a remote actor on a possibly different machine.
Obtains the ActorRef to a remote actor on a possibly different machine.
Value parameters
- ClassTag
-
A given instance of a ClassTag for the actor's message type
M
. Used internally to circumvent the JVM's type limitations. - uri
-
A URI, referencing the actor on the remote actor system. Must have the format
peloton://<host>:<port>/<actor_name>
, e.g.,peloton://192.168.100.6:5000/my_actor
.
Attributes
- Returns
-
An
IO
of ActorRef for the given URI.
Shuts down the actor system.
Shuts down the actor system.
This will also terminate all running actors. If an actor is currently processing a message, termination will wait for the message handler to finish.
Attributes
- Returns
-
IO[Unit]
Spawn a new Actor with simple, stateful behavior.
Spawn a new Actor with simple, stateful behavior.
The actor maintains an internal state which is passed to the message handler an can be updated using the context's Context.setState method. The state is kept only in memory and is not persisted in any way.
Type parameters
- M
-
The actor's message type
- S
-
The type of the actor's internal state
Value parameters
- ClassTag
-
A given instance of a ClassTag for the actor's message type
M
. Used internally to circumvent the JVM's type limitations. - initialBehavior
-
The initial behavior, i.e., the message handler function. The function takes the current state of the actor, the input (message) and the actor's Context as parameters and returns a new Behavior, depending on the state and the message. The behavior is evaluated effectful.
- initialState
-
The initial state for the actor.
- name
-
An optional name for the actor. If omitted, the actor system will create a name for the actor.
Attributes
- Returns
-
An
IO
of ActorRef
Spawns a new Actor with a durable (persistent) state.
Spawns a new Actor with a durable (persistent) state.
The DurableStateActor
is connected to a given DurableStateStore instance. A given PersistenceId
connects this actor instance to a distinct record in the state store, e.g., database row with index key.
When the actor spawns, the last known previous actor state is read from the store and used as the initial state of the actor. If no previous state was found, a given default state is used.
While processing incoming messages, the actor's Behavior can use Context.setState to update the state's representation in the DurableStateStore
.
Type parameters
- M
-
The actor's message type
- S
-
The type of the actor's internal state
Value parameters
- ClassTag
-
A given instance of a ClassTag for the actor's message type
M
. Used internally to circumvent the JVM's type limitations. - DurableStateStore
-
A given instance of DurableStateStore
- PayloadCodec
-
A given instance of a PayloadCodec for the actor's state type
S
. Used to convert the state to a byte array and vice versa. - initialBehavior
-
The initial behavior, i.e., the message handler function. The function takes the current state of the actor, the input (message) and the actor's Context as parameters and returns a new Behavior, depending on the state and the message. The behavior is evaluated effectful.
- initialState
-
A default/initial state that is used if the actor has never stored its state with the given
persistenceId
. - name
-
An optional name for the actor. If omitted, the actor system will create a name for the actor.
- persistenceId
-
A unique identifier of type PersistenceId that references the persisted state of this actor in the DurableStateStore.
Attributes
- Returns
-
An
IO
of ActorRef
Spawn a new Actor with event sourced behavior.
Spawn a new Actor with event sourced behavior.
The message processing of the event sourced actor consists of two phases:
- the message handler:
- accepts the incoming messages of type
M
- uses the provided actor context to possibly reply to the sender (e.g. in case of an ASK pattern)
- perform other actions that do not modify the state of the actor
- returns an EventAction that determines if the message has to be converted into an event (which is then written to the event store)
- the event handler:
- accepts incoming event (from the message handler or the event store)
- implements the business logic to modify the actor state
- returns the new state
So, in short, the message handler is mainly responsible to convert messages to events (which are then written to the event store) while the event handler is responsible to update the actor state.
On start, an event sourced actor will read all existing events (for the given persistence ID) from the event store and replay them using the event handler. This leaves the actor in the same state as before the last shutdown.
Unlike other actor types, the event sourced actor is not allowed to change its behavior. It will always use a behavior of type EventSourcedBehavior
Type parameters
- E
-
The actor's event type
- M
-
The actor's message type
- S
-
The type of the actor's internal state
Value parameters
- ClassTag
-
A given instance of a ClassTag for the actor's message type
M
. Used internally to circumvent the JVM's type limitations. - EventStore
-
A given instance of EventStore
- PayloadCodec
-
A given instance of a PayloadCodec for the actor's state type
S
. Used to convert the state to a byte array and vice versa. - eventHandler
-
The event handler of type EventHandler
- initialState
-
The initial state for the actor.
- messageHandler
-
The message handler of type MessageHandler
- name
-
An optional name for the actor. If omitted, the actor system will create a name for the actor.
- persistenceId
-
A unique identifier of type PersistenceId that references the persisted state of this actor in the EventStore.
- snapshotPredicate
-
A function that takes the current state of the actor (after applying the current event), the current event and the number of events that have been processed (icluding the current event) since the last snapshot. The function returns a Boolean that indicates if a new snapshot needs to be created.
Attributes
- Returns
-
An
IO
of ActorRef