TypedBus¶
Async pub/sub with typed channels and ACK-based delivery
![]() GitHub Repository |
TypedBus provides named, optionally typed pub/sub channels with explicit ACK/NACK delivery, dead letter queues, backpressure, and adaptive throttling — all within a single Async reactor. Key Features - Typed Channels - Restrict messages to a specific class - ACK-Based Delivery - Subscribers must explicitly ack or nack - Dead Letter Queues - Collect nacked and timed-out deliveries - Backpressure - Bound pending deliveries per channel - Adaptive Throttling - Progressive slowdown as capacity fills - Configuration Cascade - Global → Bus → Channel defaults - Stats Tracking - Per-channel publish/deliver/nack/timeout counters - Structured Logging - Optional Logger integration across all components |
Quick Example¶
require "typed_bus"
TypedBus.configure do |config|
config.timeout = 10
config.log_level = Logger::INFO
end
bus = TypedBus::MessageBus.new
bus.add_channel(:events, type: String)
bus.subscribe(:events) do |delivery|
puts delivery.message
delivery.ack!
end
Async do
bus.publish(:events, "hello world")
end
Requirements¶
- Ruby >= 3.2.0
- async ~> 2.0
License¶
MIT
