class

JoobQ::EventBus

Inherits Reference < Object

Delivers events to sinks from a dedicated fiber, so emitting never blocks or fails the caller. When the buffer is full the event is dropped and counted.

Constants

BATCH_SIZE = 100
ERROR_LOG_INTERVAL = 10.seconds
Log = ::Log.for("EVENTS")

Constructors

new(capacity : Int32 = 4096)
Source

Instance methods

active?
Source
close(wait : Time::Span = 2.seconds) : Nil

Stops accepting events, delivers what is buffered, and waits for the dispatcher to finish (up to wait).

Source
dropped
Source
emit(type : String, & : -> _) : Nil

The block builds the payload and only runs when someone is listening.

Source
subscribe(sink : EventSink) : Nil
Source
unsubscribe(sink : EventSink) : Nil
Source