lambdacd.event-bus
Entry-point into the LambdaCD event bus.
The event-bus exists to decouple communication between various parts of LambdaCD and allow external libraries to act on or publish events in a LambdaCD instance.
Usage example:
(let [subscription (subscribe ctx :some-topic)
payloads (only-payload subscription)]
(<! (go-loop []
(if-let [event (<! payloads)]
(do
(publish! ctx :some-other-topic (:some-value event))
(recur)))))
(unsubscribe ctx :some-topic subscription))
initialize-event-bus
(initialize-event-bus ctx)
Initialize everything necessary for an event-bus to run. Returns a ctx that contains everything necessary so others can use the event-bus later on.
only-payload
(only-payload subscription)
Takes a subscription channel and returns a channel that contains only the payload.
publish!
macro
(publish! ctx topic payload)
Publish an event on a particular topic of the event-bus when calling from a go block.
publish!!
macro
(publish!! ctx topic payload)
Publish an event on a particular topic of the event-bus when calling from a normal thread.
subscribe
(subscribe ctx topic)
Subscribe to a particular topic on the event-bus. Returns a subscription channel, i.e. a channel of events and metadata. Use only-payload to get a channel of only event payloads.
unsubscribe
(unsubscribe ctx topic subscription)
Unsubscribe from a channel. Receives the topic we want to unsubscribe from and the subscription channel returned by subscribe.