Skip to main content

SystemComponents

Trait SystemComponents 

Source
pub trait SystemComponents:
    Send
    + Sync
    + 'static {
    // Required methods
    fn deadletter_ref(&self) -> ActorRef<!>;
    fn dispatcher_ref(&self) -> ActorRefStrong<DispatchEnvelope>;
    fn system_path(&self) -> SystemPath;
    fn start(&self, _system: &KompactSystem);
    fn stop(&self, _system: &KompactSystem);
    fn stop_notify<'a>(
        &'a self,
        system: &'a KompactSystem,
    ) -> Pin<Box<dyn Future<Output = Result<(), SystemComponentsShutdownError>> + Send + 'a>>;
    fn kill(&self, _system: &KompactSystem);
    fn with_dispatcher_definition_dyn<'a>(
        &self,
        f: Box<dyn FnOnce(&mut (dyn Any + 'static)) + 'a>,
    );

    // Provided methods
    fn type_id(&self) -> TypeId { ... }
    fn with_dispatcher_definition<F>(&self, f: F)
       where Self: Sized,
             F: FnOnce(&mut (dyn Any + 'static)) { ... }
}
Expand description

A trait to provide custom implementations of all system components

Required Methods§

Source

fn deadletter_ref(&self) -> ActorRef<!>

Return a reference to this deadletter box

Source

fn dispatcher_ref(&self) -> ActorRefStrong<DispatchEnvelope>

Return a reference to this dispatcher

Source

fn system_path(&self) -> SystemPath

Return a system path for this dispatcher

Source

fn start(&self, _system: &KompactSystem)

Start all the system components

Source

fn stop(&self, _system: &KompactSystem)

Stop all the system components

Source

fn stop_notify<'a>( &'a self, system: &'a KompactSystem, ) -> Pin<Box<dyn Future<Output = Result<(), SystemComponentsShutdownError>> + Send + 'a>>

Stop all the system components and complete once shutdown has finished

Source

fn kill(&self, _system: &KompactSystem)

Stop all the system components as fast as possible, no graceful shutdown

Source

fn with_dispatcher_definition_dyn<'a>( &self, f: Box<dyn FnOnce(&mut (dyn Any + 'static)) + 'a>, )

Allow backend crates to interact with the concrete dispatcher definition.

This takes a boxed callback instead of impl FnOnce(...), because SystemComponents is used behind a trait object and generic methods would make the trait non-object-safe.

Provided Methods§

Source

fn type_id(&self) -> TypeId

Allow downcasting to concrete type

Source

fn with_dispatcher_definition<F>(&self, f: F)
where Self: Sized, F: FnOnce(&mut (dyn Any + 'static)),

Convenience wrapper for callers that work with a concrete system-components type.

Implementations§

Source§

impl dyn SystemComponents

Source

pub fn downcast<T>(&self) -> Option<&T>

Allow downcasting to concrete type

Implementors§

Source§

impl<B, C> SystemComponents for CustomComponents<B, C>
where B: ActorRaw<Message = !> + 'static + ComponentDefinition, C: ComponentDefinition<Message = DispatchEnvelope> + ActorRaw + 'static + Dispatcher,