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 with_config(broker: Arc<K2KBroker>, config: DispatcherConfig) -> Self
pub fn with_config(broker: Arc<K2KBroker>, config: DispatcherConfig) -> Self
Create a new dispatcher with custom configuration.
Sourcepub fn register<M: PersistentMessage>(&self, kernel_id: KernelId)
pub fn register<M: PersistentMessage>(&self, kernel_id: KernelId)
Sourcepub fn register_with_name<M: PersistentMessage>(
&self,
kernel_id: KernelId,
handler_name: &str,
)
pub fn register_with_name<M: PersistentMessage>( &self, kernel_id: KernelId, handler_name: &str, )
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>
pub async fn dispatch( &self, envelope: MessageEnvelope, ) -> Result<DeliveryReceipt>
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>
pub async fn dispatch_from( &self, source: KernelId, envelope: MessageEnvelope, ) -> Result<DeliveryReceipt>
Dispatch a message from a specific source kernel.
Sourcepub async fn dispatch_message<M: PersistentMessage>(
&self,
message: &M,
timestamp: HlcTimestamp,
) -> Result<DeliveryReceipt>
pub async fn dispatch_message<M: PersistentMessage>( &self, message: &M, timestamp: HlcTimestamp, ) -> Result<DeliveryReceipt>
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.