Skip to main content

Module message_router

Module message_router 

Source
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 AtomicU64 for lock-free reads.
  • No unwrap(): all fallible operations surface errors explicitly.

Structs§

HandlerRegistration
Describes a handler that the MessageRouter should dispatch messages to.
MessageRouter
Priority-based message router with per-handler queues and a dead-letter queue.
MessageRouterStats
Aggregate statistics for a PeerMessageRouter.
PeerMessageRouter
Routes messages to appropriate peer handlers based on message type and topic subscriptions, supporting both direct and broadcast routing.
PeerRoutedMessage
A message that has been routed (or queued for routing) by PeerMessageRouter.
RouteRule
A rule that influences how the PeerMessageRouter dispatches messages.
RoutedMessage
A message travelling through the router.
RouterStats
Atomic statistics counters for a MessageRouter.
RouterStatsSnapshot
Snapshot of RouterStats at a point in time.

Enums§

MessagePriority
Message priority levels.
MessageType
Classification of a message moving through the PeerMessageRouter.
RouterError
Errors that can be returned by MessageRouter.