Struct overclock::core::Rt

source ·
pub struct Rt<A: Actor<S>, S: Send> { /* private fields */ }
Expand description

The actor’s local context

Implementations§

source§

impl<A: Actor<S>, S> Rt<A, S>where Self: Send, S: Send,

source

pub fn child<D: Into<String>>(&self, dir_name: D) -> LocateScopeId

Start traversing from the child with the provided dir name

source

pub fn parent(&self) -> LocateScopeId

Start traversing from the parent

source

pub fn sibling<D: Into<String>>(&self, dir_name: D) -> LocateScopeId

Start traversing from the sibling with the provided dir name

source

pub fn grandparent(&self) -> LocateScopeId

Start traversing from the grand parent

source

pub fn uncle<D: Into<String>>(&self, dir_name: D) -> LocateScopeId

Start traversing from the uncle

source

pub fn abortable<F>(&self, fut: F) -> Abortable<F> where F: Future + Send + Sync,

Create abortable future which will be aborted if the actor got shutdown signal.

source

pub async fn start<Dir: Into<Option<String>>, Child>( &mut self, directory: Dir, child: Child ) -> ActorResult<<Child::Channel as Channel>::Handle>where Child: 'static + Actor<<A::Channel as Channel>::Handle> + ChannelBuilder<Child::Channel>, <A::Channel as Channel>::Handle: SupHandle<Child>, Self: Send,

Spawn the provided child and await till it’s initialized

source

pub async fn spawn<Dir, Child>( &mut self, directory: Dir, child: Child ) -> ActorResult<(<Child::Channel as Channel>::Handle, InitializedRx)>where <A::Channel as Channel>::Handle: Clone + SupHandle<Child>, Child: 'static + ChannelBuilder<<Child as Actor<<A::Channel as Channel>::Handle>>::Channel> + Actor<<A::Channel as Channel>::Handle>, Child::Channel: Send, <Child as Actor<<A::Channel as Channel>::Handle>>::Channel: Send, Dir: Into<Option<String>>,

Spawn the child, and returns its handle and initialized rx to check if it got initialized

source

pub async fn start_with_channel<Dir: Into<Option<String>>, Child>( &mut self, directory: Dir, child: Child, channel: Child::Channel ) -> ActorResult<<Child::Channel as Channel>::Handle>where Child: 'static + Actor<<A::Channel as Channel>::Handle>, <A::Channel as Channel>::Handle: SupHandle<Child>, Self: Send,

Spawn the provided child and await till it’s initialized

source

pub async fn spawn_with_channel<Dir, Child>( &mut self, directory: Dir, child: Child, channel: Child::Channel ) -> ActorResult<(<Child::Channel as Channel>::Handle, InitializedRx)>where <A::Channel as Channel>::Handle: Clone + SupHandle<Child>, Child: 'static + Actor<<A::Channel as Channel>::Handle>, Dir: Into<Option<String>>,

Spawn the child, and returns its handle and initialized rx to check if it got initialized

source

pub fn upsert_microservice(&mut self, scope_id: ScopeId, service: Service)

Insert/Update microservice. Note: it will remove the children handles/joins if the provided service is stopped and store entry for it in inactive if does have directory

source

pub fn remove_microservice(&mut self, scope_id: ScopeId)

Remove the microservice microservice under the provided scope_id

source

pub fn inbox_mut(&mut self) -> &mut <A::Channel as Channel>::Inbox

Returns mutable reference to the actor’s inbox

source

pub fn handle_mut(&mut self) -> &mut <A::Channel as Channel>::Handle

Returns mutable reference to the actor’s handle

source

pub fn handle(&self) -> &<A::Channel as Channel>::Handle

Returns immutable reference to the actor’s handle

source

pub fn supervisor_handle_mut(&mut self) -> &mut S

Returns mutable reference to the actor’s supervisor handle

source

pub fn supervisor_handle(&self) -> &S

Returns immutable reference to the actor’s supervisor handle

source

pub fn service(&self) -> &Service

Get the local service

source

pub fn scope_id(&self) -> ScopeId

Return the actor’s scope id

source

pub fn depth(&self) -> Depth

Return the actor’s depth

source

pub fn parent_id(&self) -> Option<ScopeId>

Return the actor parent’s scope id

source

pub async fn shutdown_scope(&self, scope_id: ScopeId) -> Result<()>where Self: Send,

Shutdown the scope under the provided scope_id

source

pub fn microservices_stopped(&self) -> bool

Check if microservices are stopped

source

pub fn microservices_all(&self, are: fn(_: &Service) -> bool) -> bool

Check if all microservices are _

source

pub fn microservices_any(&self, is: fn(_: &Service) -> bool) -> bool

Check if any microservice is _

source

pub async fn shutdown_children(&mut self)

Shutdown all the children within this actor context

source

pub async fn shutdown_child( &mut self, child_scope_id: &ScopeId ) -> Option<JoinHandle<ActorResult<()>>>

Shutdown child using its scope_id

source

pub async fn shutdown_children_type<T: 'static + Actor<<A::Channel as Channel>::Handle>>( &mut self ) -> HashMap<ScopeId, JoinHandle<ActorResult<()>>>where <A::Channel as Channel>::Handle: SupHandle<T>,

Shutdown all the children of a given type within this actor context

source

pub async fn add_route<T: Send + 'static>(&self) -> Result<()>where <A::Channel as Channel>::Handle: Route<T>,

Add route for T

source

pub async fn remove_route<T: Send + 'static>(&self) -> Result<()>

Remove route of T

source

pub async fn send<T: Send + 'static>( &self, scope_id: ScopeId, message: T ) -> Result<()>where Self: Send + Sync,

Try to send message T, to the provided scope_i

source§

impl<A: Actor<S>, S: SupHandle<A>> Rt<A, S>where Self: Send,

source

pub async fn update_status(&mut self, service_status: ServiceStatus)

Update the service status, and report to the supervisor and subscribers (if any)

source

pub async fn stop(&mut self)

Stop the microservices and update status to stopping

source§

impl<A: Actor<S>, S: SupHandle<A>> Rt<A, S>

source

pub fn new( depth: usize, service: Service, scopes_index: usize, scope_id: ScopeId, parent_scope_id: Option<ScopeId>, sup_handle: S, handle: <A::Channel as Channel>::Handle, inbox: <A::Channel as Channel>::Inbox, abort_registration: AbortRegistration, visible_data: HashSet<TypeId> ) -> Self

Create Overclock context

source

pub fn register<T: Collector + Clone + 'static>( &mut self, metric: T ) -> Result<()>

Register a metric

source§

impl<A: Actor<S>, S: SupHandle<A>> Rt<A, S>

source

pub async fn add_resource<T: Resource>(&mut self, resource: T)

Add exposed resource

source

pub async fn expose<T: Resource>(&mut self)

Expose resource as visible data

source

pub async fn highest_scope_id<T: Resource>(&self) -> Option<ScopeId>

Get the highest resource’s scope id (at the most top level) for a given global visiable resource

source

pub async fn lowest_scope_id<T: Resource>(&self) -> Option<ScopeId>

Gets the lowest resource’s scope id for a given global visiable resource

source

pub async fn try_borrow<'a, T: Resource, R>( &self, resource_scope_id: ScopeId, fn_once: fn(_: &T) -> R ) -> Option<R::Output>where R: Future + Send + 'static,

Try to borrow resource and invoke fn_once

source

pub async fn try_borrow_mut<'a, T: Resource, R>( &self, resource_scope_id: ScopeId, fn_once: fn(_: &T) -> R ) -> Option<R::Output>where R: Future + Send + 'static,

Try to borrow_mut the resource and invoke fn_once

source

pub async fn publish<T: Resource>(&self, resource: T)

Publish resource

source

pub async fn lookup<T: Resource>(&self, resource_scope_id: ScopeId) -> Option<T>

Lookup for resource T under the provider scope_id

source

pub async fn remove_resource<T: Resource>(&self) -> Option<T>

Remove the resource, and inform the interested dyn subscribers

source

pub async fn depends_on<T: Resource>( &self, resource_scope_id: ScopeId ) -> Result<T, Error>

Depends on resource T, it will await/block till the resource is available

Link to resource, which will await till it’s available. NOTE: similar to depends_on, but only shutdown self actor if the resource got dropped hard_link: if shutdown the subscriber when the publisher publishes a new copy

source

pub async fn subscribe<T: Resource>( &self, resource_scope_id: ScopeId, resource_ref: ResourceRef ) -> Result<Option<T>, Error>where <A::Channel as Channel>::Handle: Route<Event<T>>,

Depends on dynamic Resource T

Auto Trait Implementations§

§

impl<A, S> !RefUnwindSafe for Rt<A, S>

§

impl<A, S> Send for Rt<A, S>

§

impl<A, S> Sync for Rt<A, S>where S: Sync,

§

impl<A, S> Unpin for Rt<A, S>where S: Unpin, <<A as Actor<S>>::Channel as Channel>::Handle: Unpin, <<A as Actor<S>>::Channel as Channel>::Inbox: Unpin,

§

impl<A, S> !UnwindSafe for Rt<A, S>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<E, T, const C: usize> ChannelBuilder<AbortableBoundedChannel<E, C>> for Twhere E: Send + 'static, T: Send,

source§

fn build_channel<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<AbortableBoundedChannel<E, C>, ActorError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, T: 'async_trait,

Implement how to build the channel for the corresponding actor
source§

impl<E, T> ChannelBuilder<AbortableUnboundedChannel<E>> for Twhere E: Send + 'static, T: Send,

source§

fn build_channel<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<AbortableUnboundedChannel<E>, ActorError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, T: 'async_trait,

Implement how to build the channel for the corresponding actor
source§

impl<E, T, const C: usize> ChannelBuilder<BoundedChannel<E, C>> for Twhere E: ShutdownEvent + 'static, T: Send,

source§

fn build_channel<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<BoundedChannel<E, C>, ActorError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, T: 'async_trait,

Implement how to build the channel for the corresponding actor
source§

impl<T, const I: u64> ChannelBuilder<IntervalChannel<I>> for Twhere T: Send,

source§

fn build_channel<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<IntervalChannel<I>, ActorError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, T: 'async_trait,

Implement how to build the channel for the corresponding actor
source§

impl<T, C, B> ChannelBuilder<Marker<C, B>> for Twhere B: Send + 'static + Sync, T: Send + ChannelBuilder<C>, C: Channel,

source§

fn build_channel<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<Marker<C, B>, ActorError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, T: 'async_trait,

Implement how to build the channel for the corresponding actor
source§

impl<T> ChannelBuilder<NullChannel> for Twhere T: Send,

source§

fn build_channel<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<NullChannel, ActorError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, T: 'async_trait,

Implement how to build the channel for the corresponding actor
source§

impl<E, T> ChannelBuilder<UnboundedChannel<E>> for Twhere E: ShutdownEvent + 'static, T: Send,

source§

fn build_channel<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Result<UnboundedChannel<E>, ActorError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, T: 'async_trait,

Implement how to build the channel for the corresponding actor
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V