Struct KernelDispatcher
pub struct KernelDispatcher {
routes: RwLock<RawRwLock, HashMap<u64, KernelId>>,
handler_tables: RwLock<RawRwLock, HashMap<KernelId, DispatchTable>>,
broker: Arc<K2KBroker>,
config: DispatcherConfig,
metrics: RwLock<RawRwLock, DispatcherMetrics>,
}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.
Fields§
§routes: RwLock<RawRwLock, HashMap<u64, KernelId>>§handler_tables: RwLock<RawRwLock, HashMap<KernelId, DispatchTable>>§broker: Arc<K2KBroker>§config: DispatcherConfig§metrics: RwLock<RawRwLock, DispatcherMetrics>Implementations§
§impl KernelDispatcher
impl KernelDispatcher
pub fn builder() -> DispatcherBuilder
pub fn builder() -> DispatcherBuilder
Create a new dispatcher builder.
pub fn new(broker: Arc<K2KBroker>) -> KernelDispatcher
pub fn new(broker: Arc<K2KBroker>) -> KernelDispatcher
Create a new dispatcher with the given broker.
pub 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.
pub fn register<M>(&self, kernel_id: KernelId) -> Result<(), RingKernelError>where
M: PersistentMessage,
pub fn register<M>(&self, kernel_id: KernelId) -> Result<(), RingKernelError>where
M: PersistentMessage,
pub fn register_with_name<M>(
&self,
kernel_id: KernelId,
handler_name: &str,
) -> Result<(), RingKernelError>where
M: PersistentMessage,
pub fn register_with_name<M>(
&self,
kernel_id: KernelId,
handler_name: &str,
) -> Result<(), RingKernelError>where
M: PersistentMessage,
Register a message type with a custom handler name.
pub 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).
pub fn unregister(&self, type_id: u64)
pub fn unregister(&self, type_id: u64)
Unregister a message type.
pub 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).
pub 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
pub 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.
pub 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.
pub fn metrics(&self) -> DispatcherMetrics
pub fn metrics(&self) -> DispatcherMetrics
Get current metrics.
pub 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§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§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>
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