pub struct InstanceWrapper<M: RemoteMessage> { /* private fields */ }Expand description
Wrapper around an instance of an actor that provides utilities to implement a python actor. This helps by allowing users to specialize the actor to the message type they want to handle.
Implementations§
Source§impl<M: RemoteMessage> InstanceWrapper<M>
impl<M: RemoteMessage> InstanceWrapper<M>
pub fn new(proc: &PyProc, actor_name: &str) -> Result<Self>
Sourcepub fn send(&self, actor_id: &PyActorId, message: &PySerialized) -> PyResult<()>
pub fn send(&self, actor_id: &PyActorId, message: &PySerialized) -> PyResult<()>
Send a message to any actor. It is the responsibility of the caller to ensure the right payload accepted by the target actor has been serialized and provided to this function.
Sourcepub async fn next_message(
&mut self,
timeout_msec: Option<u64>,
) -> Result<Option<M>>
pub async fn next_message( &mut self, timeout_msec: Option<u64>, ) -> Result<Option<M>>
Get the next message from the queue. It will wait until a message is received or the timeout is reached in which case it will return None.
Sourcepub fn drain_and_stop(&mut self) -> Result<Vec<M>>
pub fn drain_and_stop(&mut self) -> Result<Vec<M>>
Put the actor in stopped mode and return any messages that were received.
pub fn instance(&self) -> &Instance<()>
pub fn actor_id(&self) -> &ActorId
Auto Trait Implementations§
impl<M> Freeze for InstanceWrapper<M>
impl<M> !RefUnwindSafe for InstanceWrapper<M>
impl<M> Send for InstanceWrapper<M>
impl<M> Sync for InstanceWrapper<M>
impl<M> Unpin for InstanceWrapper<M>
impl<M> !UnwindSafe for InstanceWrapper<M>
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].