runa/crates/runa-actor/src/lib.rs

72 lines
1.6 KiB
Rust

//! Value contracts for the single-worker actor prototype.
use runa_core::ImplementationId;
pub use runa_core::{ActorRef, Value};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct MailboxId(pub u64);
pub type Message = Value;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Envelope {
pub sender: Option<ActorRef>,
pub message: Message,
}
/// Privileged worker commands; never representable as actor message data.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SystemMessage {
Stop,
Kill,
Restart,
Pause,
Resume,
Reload(ImplementationId),
Become(ImplementationId),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Status {
Idle,
Running,
Awaiting,
Paused,
Stopped,
Failed(String),
}
#[derive(Debug, Clone)]
pub struct ActorSnapshot {
pub actor_ref: ActorRef,
pub mailbox: MailboxId,
pub implementation: ImplementationId,
pub incarnation: u64,
pub state: Value,
pub status: Status,
pub execution: Option<ExecutionSnapshot>,
pub queued: Vec<Message>,
pub reserved: Option<Message>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ExecutionSnapshot {
pub vm_steps: u64,
pub instruction_pointer: usize,
pub call_depth: usize,
}
#[derive(Debug, Clone)]
pub enum Event {
Spawned(ActorRef),
Committed(ActorRef),
Failed(ActorRef, String),
Stopped(ActorRef),
Restarted(ActorRef),
Paused(ActorRef),
Resumed(ActorRef),
InvocationCancelled(ActorRef),
BehaviorInstalled(ActorRef, ImplementationId),
StateMigrated(ActorRef, Value, Value),
}