BaileysEx.Connection.EventEmitter (baileys_ex v0.1.0-alpha.12)

Copy Markdown View Source

Supervised buffered connection event emitter modeled after Baileys' makeEventBuffer.

Each emitter owns its buffering server and callback task supervisor. Internal taps remain ordered, while each public subscriber has an independent serial, bounded delivery lane. Slow or reentrant subscribers therefore do not block event ingestion or internal protocol handling.

Summary

Functions

Enter buffering mode.

Return whether buffering is active.

Wrap work in a nested buffering context.

Emit one event, buffering it when the current buffer policy requires it.

Flush the active buffer, retaining it when the dispatch queue is full.

Register an event-map subscriber and return its unsubscribe function.

Add values used by conditional buffered-event evaluation.

Start a supervised event emitter runtime.

Register a pre-dispatch tap and return its unsubscribe function.

Types

emit_error()

@type emit_error() :: :dispatch_queue_full

event()

@type event() :: atom()

Functions

buffer(emitter)

@spec buffer(GenServer.server()) :: :ok

Enter buffering mode.

buffering?(emitter)

@spec buffering?(GenServer.server()) :: boolean()

Return whether buffering is active.

create_buffered_function(emitter, work)

@spec create_buffered_function(GenServer.server(), (-> term())) :: (-> term())

Wrap work in a nested buffering context.

emit(emitter, event, data)

@spec emit(GenServer.server(), event(), term()) :: :ok | {:error, emit_error()}

Emit one event, buffering it when the current buffer policy requires it.

flush(emitter)

@spec flush(GenServer.server()) :: boolean() | {:error, emit_error()}

Flush the active buffer, retaining it when the dispatch queue is full.

process(emitter, handler)

@spec process(GenServer.server(), (map() -> term())) :: (-> :ok)

Register an event-map subscriber and return its unsubscribe function.

seed(emitter, values)

@spec seed(GenServer.server(), map()) :: :ok

Add values used by conditional buffered-event evaluation.

start_link(opts \\ [])

@spec start_link(keyword()) :: Supervisor.on_start()

Start a supervised event emitter runtime.

tap(emitter, handler)

@spec tap(GenServer.server(), (map() -> term())) :: (-> :ok)

Register a pre-dispatch tap and return its unsubscribe function.