Kepler.Sink.Callback (Kepler v0.1.0)

Copy Markdown View Source

Calls a function in your application with each event.

Use this when the event should go somewhere Kepler has no business knowing about — your own Oban worker, a PubSub broadcast, a test process.

config :kepler,
  sinks: [alerts: {Kepler.Sink.Callback, handler: {MyApp.Alerts, :handle_kepler_event}}]

:handler is either a one-arity function or a {module, function} pair. The module and function must exist at boot, so a typo is a boot failure rather than a silent non-delivery.

In tests, a closure over the test pid is usually what you want:

[test: {Kepler.Sink.Callback, handler: &send(test_pid, {:kepler, &1})}]

The handler runs in a supervised task, not on the poller, so it may block — but it is called once per event with no retry, and raising counts as a failed delivery.

Handing the event to a queue you already run is the supported way to get at-least-once delivery. Kepler deliberately has no durable buffer of its own, so this is the seam where you add one.