Expand description
MessageRouter — Priority-based message dispatch with dead-letter queue.
Routes incoming RoutedMessages to registered HandlerRegistrations using
exact-match or wildcard topic patterns. Each handler maintains its own
BinaryHeap-backed priority queue. Messages that match no handler are
forwarded to a bounded dead-letter queue.
§Design highlights
- Priority dispatch: handlers are stored sorted by priority descending so higher-priority handlers are always evaluated first.
- Wildcard matching: supports exact match, prefix wildcard (
block.*), and catch-all (*). - Dead-letter queue: bounded at 100 items; oldest entries are evicted when full.
- Atomic statistics: all counters use
AtomicU64for lock-free reads. - No
unwrap(): all fallible operations surface errors explicitly.
Structs§
- Handler
Registration - Describes a handler that the
MessageRoutershould dispatch messages to. - Message
Router - Priority-based message router with per-handler queues and a dead-letter queue.
- Message
Router Stats - Aggregate statistics for a
PeerMessageRouter. - Peer
Message Router - Routes messages to appropriate peer handlers based on message type and topic subscriptions, supporting both direct and broadcast routing.
- Peer
Routed Message - A message that has been routed (or queued for routing) by
PeerMessageRouter. - Route
Rule - A rule that influences how the
PeerMessageRouterdispatches messages. - Routed
Message - A message travelling through the router.
- Router
Stats - Atomic statistics counters for a
MessageRouter. - Router
Stats Snapshot - Snapshot of
RouterStatsat a point in time.
Enums§
- Message
Priority - Message priority levels.
- Message
Type - Classification of a message moving through the
PeerMessageRouter. - Router
Error - Errors that can be returned by
MessageRouter.