class

Bus

Inherits Reference < Object

A Bus sends messages to interested subscribers. Those subscribers can reply to a message. Those replies will be routed back to the original sender.

Constants

VERSION = "0.1.1"

Constructors

Instance methods

has_subscription?(key)
Source
message(body : Array(String) | String, origin : String | Nil = nil, tags : Array(String) = [] of String, parameters : Hash(String, String) = Hash(String, String).new, strategy : Message::Strategy = Message::Strategy::RandomWinner)

Generate a message for this bus.

Source
origin_tag

Generate a random UUID that does not already exist in the subscriptions.

Source
pipeline
Source
send(body : Array(String) | String, origin : String | Nil = nil, tags : Array(String) = [] of String, parameters : Hash(String, String) = Hash(String, String).new, strategy : Message::Strategy = Message::Strategy::RandomWinner)
Source
send(message : Message)

Send a message to the subscribers

Source
subscribe(tags = [] of String)

Subscribe a new message consumer to the Bus

Source
subscriptions

As of Crystal 1.0.0, using Hashes here is faster in single threaded release mode, but it fails UGLY in multithreaded release mode. The SplayTreeMap implementation is currently slightly slower than the hash in single threaded, but it works just fine in multithreaded mode, so this implementation is going to stick with the SplayTreeMap for now.

Source
unsubscribe(pipeline)

Remove a message consumer from the Bus

Source

Nested types