pub struct ConcurrentActor {
pub id: String,
pub actor_type: String,
pub state: Arc<RwLock<HashMap<String, ActorFieldValue>>>,
pub lifecycle_state: Arc<RwLock<ActorState>>,
pub mailbox_sender: Sender<Envelope>,
pub thread_handle: Option<JoinHandle<()>>,
pub children: Arc<RwLock<Vec<String>>>,
pub supervisor: Option<String>,
pub supervision_strategy: SupervisionStrategy,
pub restart_count: Arc<Mutex<u32>>,
pub last_restart: Arc<Mutex<Instant>>,
}Expand description
Concurrent actor instance with its own thread
Fields§
§id: String§actor_type: String§state: Arc<RwLock<HashMap<String, ActorFieldValue>>>§lifecycle_state: Arc<RwLock<ActorState>>§mailbox_sender: Sender<Envelope>§thread_handle: Option<JoinHandle<()>>§children: Arc<RwLock<Vec<String>>>§supervisor: Option<String>§supervision_strategy: SupervisionStrategy§restart_count: Arc<Mutex<u32>>§last_restart: Arc<Mutex<Instant>>Implementations§
Source§impl ConcurrentActor
impl ConcurrentActor
Sourcepub fn new(
id: String,
actor_type: String,
initial_state: HashMap<String, ActorFieldValue>,
supervisor: Option<String>,
) -> Self
pub fn new( id: String, actor_type: String, initial_state: HashMap<String, ActorFieldValue>, supervisor: Option<String>, ) -> Self
Create a new concurrent actor
Sourcepub fn start(
&mut self,
receive_handlers: HashMap<String, String>,
) -> Result<(), InterpreterError>
pub fn start( &mut self, receive_handlers: HashMap<String, String>, ) -> Result<(), InterpreterError>
Start the actor’s execution thread
Sourcepub fn stop(&mut self) -> Result<(), InterpreterError>
pub fn stop(&mut self) -> Result<(), InterpreterError>
Stop the actor
Sourcepub fn send(
&self,
message: ActorMessage,
from: Option<String>,
) -> Result<(), InterpreterError>
pub fn send( &self, message: ActorMessage, from: Option<String>, ) -> Result<(), InterpreterError>
Send a message to this actor
Sourcepub fn should_restart(&self) -> bool
pub fn should_restart(&self) -> bool
Check if actor should be restarted based on supervision strategy
Auto Trait Implementations§
impl Freeze for ConcurrentActor
impl !RefUnwindSafe for ConcurrentActor
impl Send for ConcurrentActor
impl Sync for ConcurrentActor
impl Unpin for ConcurrentActor
impl !UnwindSafe for ConcurrentActor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more