Cyclium.Bus (Cyclium v0.1.9)

Copy Markdown View Source

Event pub/sub that connects actors without coupling.

Two event layers:

  • Layer A: Domain events (emitted by your application)
  • Layer B: Runtime events (emitted by Cyclium internals)

Built on Phoenix.PubSub. The consuming app provides the PubSub process via Cyclium.Supervisor opts.

Summary

Functions

Publish to both the global topic and the event-specific topic, so both broad and targeted subscribers receive the event.

Publish an event to the bus. All subscribers receive {:bus, event_type, payload}.

Subscribe the calling process to all bus events. Messages arrive as {:bus, event_type, payload}.

Subscribe to a specific event type topic. Messages arrive as {:bus, event_type, payload}.

Functions

broadcast(event_type, payload \\ %{})

Publish to both the global topic and the event-specific topic, so both broad and targeted subscribers receive the event.

publish(event_type, payload \\ %{})

Publish an event to the bus. All subscribers receive {:bus, event_type, payload}.

runtime_events()

subscribe()

Subscribe the calling process to all bus events. Messages arrive as {:bus, event_type, payload}.

subscribe(event_type)

Subscribe to a specific event type topic. Messages arrive as {:bus, event_type, payload}.