A lightweight event bus and message abstraction layer for MoonBit.
pub(all) struct BusConfig {
mode : PublishMode
keep_history : Bool
keep_dead_letters : Bool
} derive(Eq, Debug)fn BusConfig::BusConfig(mode? : PublishMode, keep_history? : Bool, keep_dead_letters? : Bool) -> BusConfigpub(all) struct DeliveryReport {
subscriber_id : String
topic : String
status : DeliveryStatus
} derive(Eq, Debug)pub(all) struct EventBus {
config : BusConfig
subscribers : Array[Subscriber]
history : Array[Message]
dead_letters : Array[DeadLetter]
} derive(Debug)fn EventBus::publish(self : EventBus, topic : StringView, payload? : StringView, source? : StringView, trace_id? : StringView, tags? : ArrayView[String], headers? : Map[String, String]) -> PublishReportfn EventBus::subscribe(self : EventBus, id : StringView, pattern : StringView, handler : (Message) -> DeliveryStatus, priority? : Int, once? : Bool) -> Unitfn FakePublisher::emit_payload(self : FakePublisher, topic : StringView, payload : StringView) -> PublishReportpub(all) struct PublishReport {
message_id : String
topic : String
matched : Int
delivered : Int
rejected : Int
skipped : Int
reports : Array[DeliveryReport]
} derive(Eq, Debug)pub(all) struct Subscriber {
id : String
pattern : TopicPattern
priority : Int
once : Bool
active : Bool
handler : (Message) -> DeliveryStatus
} derive(Debug)fn Subscriber::Subscriber(id : StringView, pattern : StringView, handler : (Message) -> DeliveryStatus, priority? : Int, once? : Bool) -> SubscriberInstall
Download zipA lightweight event bus and message abstraction layer for MoonBit.