StateActor

cc.otavia.core.actor.StateActor
abstract class StateActor[M <: Call]

Pure business logic actor with no IO capabilities. Scheduled in Phase 3 of the ActorThread event loop with a time budget, ensuring fair scheduling among many business actors.

Override resumeAsk and/or resumeNotice to handle messages. Do NOT use this actor for direct network IO — use ChannelsActor or its subclasses instead.

Type parameters

M

the type of messages this actor can handle

Attributes

Graph
Supertypes
trait Actor[M]
class Object
trait Matchable
class Any
Known subtypes
class MainActor
class ProbeActor[M, R]

Members list

Value members

Concrete methods

override def self: ActorAddress[M]

self address of this actor instance

self address of this actor instance

Attributes

Returns

self address

Definition Classes
AbstractActor

Inherited methods

final def actorId: Long

The unique id of this actor distributed by ActorSystem, when a actor instance is mounted to a ActorSystem, the actor system will distribute a unique id to the instance.

The unique id of this actor distributed by ActorSystem, when a actor instance is mounted to a ActorSystem, the actor system will distribute a unique id to the instance.

Attributes

Returns

id number

Inherited from:
Actor
final def autowire[A <: Actor[_] : ClassTag](qualifier: String): Address[MessageOf[A]]

Attributes

Inherited from:
Actor
final def autowire[A <: Actor[_] : ClassTag](qualifier: Option[String] = ..., remote: Option[String] = ...): Address[MessageOf[A]]

Attributes

Inherited from:
Actor
def batchable: Boolean

Whether this actor supports batch message processing. When true, the ActorSystem dispatches multiple messages in bulk rather than individually.

Whether this actor supports batch message processing. When true, the ActorSystem dispatches multiple messages in bulk rather than individually.

Attributes

Inherited from:
Actor
final override def context: ActorContext

Context of this actor. This method can only used after actor instance mount to actor system

Context of this actor. This method can only used after actor instance mount to actor system

Attributes

Definition Classes
AbstractActor -> Actor
Inherited from:
AbstractActor (hidden)
def maxBatchSize: Int

Maximum number of messages per batch. Used by the scheduling system.

Maximum number of messages per batch. Used by the scheduling system.

Attributes

Inherited from:
Actor

Attributes

Inherited from:
Actor
def nice: Int

Attributes

Inherited from:
Actor
final protected def noticeSelfHead(call: Notice & M): Unit

Send a Notice to self, placing it at the head of the notice mailbox (highest priority within notices). Useful for self-triggered processing that should be handled before other pending notices.

Send a Notice to self, placing it at the head of the notice mailbox (highest priority within notices). Useful for self-triggered processing that should be handled before other pending notices.

Attributes

Inherited from:
AbstractActor (hidden)
protected def resumeAsk(stack: AskStack[M & Ask[_ <: Reply]]): StackYield

Handle an Ask message received by this actor, or resume a suspended stack when the awaited reply arrives. * Match on stack.state to determine the current execution point:

Handle an Ask message received by this actor, or resume a suspended stack when the awaited reply arrives. * Match on stack.state to determine the current execution point:

override protected def resumeAsk(stack: AskStack[MyAsk]): StackYield =
  stack.state match
    case _: StartState =>
      val state = FutureState[MyReply]()
      address.ask(MyRequest(), state.future)
      stack.suspend(state)
    case state: FutureState[MyReply] =>
      stack.return(state.future.getNow)

Value parameters

stack

the ask stack containing the received Ask message and current execution state

Attributes

Returns

StackYieldStackYield returned by Stack.suspend to yield with a state, or by AskStack.return to complete with a reply

Inherited from:
AbstractActor (hidden)
protected def resumeBatchAsk(stack: BatchAskStack[M & Ask[_ <: Reply]]): StackYield

Handle a batch of Ask messages received by this actor.

Handle a batch of Ask messages received by this actor.

Value parameters

stack

the batch ask stack containing all received Ask messages

Attributes

Returns

StackYieldStackYield returned by Stack.suspend to yield with a state, or by BatchAskStack.return to complete

Inherited from:
AbstractActor (hidden)
protected def resumeBatchNotice(stack: BatchNoticeStack[M & Notice]): StackYield

Handle a batch of Notice messages received by this actor.

Handle a batch of Notice messages received by this actor.

Value parameters

stack

the batch notice stack containing all received Notice messages

Attributes

Returns

StackYieldStackYield returned by Stack.suspend to yield with a state, or by BatchNoticeStack.return to complete

Inherited from:
AbstractActor (hidden)
protected def resumeNotice(stack: NoticeStack[M & Notice]): StackYield

Handle a Notice message received by this actor, or resume a suspended stack when the awaited reply arrives.

Handle a Notice message received by this actor, or resume a suspended stack when the awaited reply arrives.

Value parameters

stack

the notice stack containing the received Notice message and current execution state

Attributes

Returns

StackYieldStackYield returned by Stack.suspend to yield with a state, or by NoticeStack.return to complete

Inherited from:
AbstractActor (hidden)
final def system: ActorSystem

The ActorSystem of this actor instance is running

The ActorSystem of this actor instance is running

Attributes

Returns

ActorSystem

Inherited from:
Actor
final def timer: Timer

Attributes

Inherited from:
Actor

Inherited fields

val batchAskFilter: (Ask[_]) => Boolean

Filter function for batching Ask messages. Return true to include in batch.

Filter function for batching Ask messages. Return true to include in batch.

Attributes

Inherited from:
Actor
val batchNoticeFilter: Notice => Boolean

Filter function for batching Notice messages. Return true to include in batch.

Filter function for batching Notice messages. Return true to include in batch.

Attributes

Inherited from:
Actor
protected var logger: Logger

Logger for this actor instance, initialized during mount.

Logger for this actor instance, initialized during mount.

Attributes

Inherited from:
AbstractActor (hidden)