pub struct KernelDispatcher { /* private fields */ }Expand description
Routes messages by type_id to registered handler kernels.
The dispatcher maintains a routing table mapping message type IDs to kernel IDs. When a message envelope is dispatched, the dispatcher looks up the type_id in the routing table and forwards the message to the appropriate kernel via the K2K broker.
Implementations§
Source§impl KernelDispatcher
impl KernelDispatcher
Sourcepub fn builder() -> DispatcherBuilder
pub fn builder() -> DispatcherBuilder
Create a new dispatcher builder.
Sourcepub fn new(broker: Arc<K2KBroker>) -> KernelDispatcher
pub fn new(broker: Arc<K2KBroker>) -> KernelDispatcher
Create a new dispatcher with the given broker.
Sourcepub fn with_config(
broker: Arc<K2KBroker>,
config: DispatcherConfig,
) -> KernelDispatcher
pub fn with_config( broker: Arc<K2KBroker>, config: DispatcherConfig, ) -> KernelDispatcher
Create a new dispatcher with custom configuration.
Sourcepub fn register<M>(&self, kernel_id: KernelId)where
M: PersistentMessage,
pub fn register<M>(&self, kernel_id: KernelId)where
M: PersistentMessage,
Sourcepub fn register_with_name<M>(&self, kernel_id: KernelId, handler_name: &str)where
M: PersistentMessage,
pub fn register_with_name<M>(&self, kernel_id: KernelId, handler_name: &str)where
M: PersistentMessage,
Register a message type with a custom handler name.
Sourcepub fn register_route(&self, type_id: u64, kernel_id: KernelId)
pub fn register_route(&self, type_id: u64, kernel_id: KernelId)
Register a route with explicit type_id (for dynamic registration).
Sourcepub fn unregister(&self, type_id: u64)
pub fn unregister(&self, type_id: u64)
Unregister a message type.
Sourcepub fn get_route(&self, type_id: u64) -> Option<KernelId>
pub fn get_route(&self, type_id: u64) -> Option<KernelId>
Get the kernel ID for a message type.
Sourcepub fn get_dispatch_table(&self, kernel_id: &KernelId) -> Option<DispatchTable>
pub fn get_dispatch_table(&self, kernel_id: &KernelId) -> Option<DispatchTable>
Get the dispatch table for a kernel (for CUDA codegen).
Sourcepub async fn dispatch(
&self,
envelope: MessageEnvelope,
) -> Result<DeliveryReceipt, RingKernelError>
pub async fn dispatch( &self, envelope: MessageEnvelope, ) -> Result<DeliveryReceipt, RingKernelError>
Dispatch a message envelope to the appropriate kernel.
The type_id from the envelope header is used to look up the destination kernel. If no route exists for the type_id, returns an error.
§Returns
Ok(DeliveryReceipt)with delivery statusErr(RingKernelError::UnknownMessageType)if no route exists
Sourcepub async fn dispatch_from(
&self,
source: KernelId,
envelope: MessageEnvelope,
) -> Result<DeliveryReceipt, RingKernelError>
pub async fn dispatch_from( &self, source: KernelId, envelope: MessageEnvelope, ) -> Result<DeliveryReceipt, RingKernelError>
Dispatch a message from a specific source kernel.
Sourcepub async fn dispatch_message<M>(
&self,
message: &M,
timestamp: HlcTimestamp,
) -> Result<DeliveryReceipt, RingKernelError>where
M: PersistentMessage,
pub async fn dispatch_message<M>(
&self,
message: &M,
timestamp: HlcTimestamp,
) -> Result<DeliveryReceipt, RingKernelError>where
M: PersistentMessage,
Dispatch a typed message.
Creates an envelope from the message and dispatches it.
Sourcepub fn metrics(&self) -> DispatcherMetrics
pub fn metrics(&self) -> DispatcherMetrics
Get current metrics.
Sourcepub fn reset_metrics(&self)
pub fn reset_metrics(&self)
Reset metrics.
Auto Trait Implementations§
impl !Freeze for KernelDispatcher
impl !RefUnwindSafe for KernelDispatcher
impl Send for KernelDispatcher
impl Sync for KernelDispatcher
impl Unpin for KernelDispatcher
impl !UnwindSafe for KernelDispatcher
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
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>
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>
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