Chronicle.WebHooks.Webhook behaviour (cratis_chronicle v1.0.3)

Copy Markdown View Source

Behaviour and macro for defining discoverable Chronicle webhooks.

Discoverable webhooks follow the same pattern as read models and constraints: metadata is captured at compile time and exposed through __chronicle_webhook__/1.

Usage

defmodule MyApp.WebHooks.AccountEvents do
  use Chronicle.WebHooks.Webhook,
    target_url: "https://example.com/chronicle/webhooks"

  alias Chronicle.WebHooks.DefinitionBuilder

  @impl true
  def define(builder) do
    builder
    |> DefinitionBuilder.with_event_type(MyApp.Events.AccountOpened)
    |> DefinitionBuilder.with_header("x-source", "my-app")
  end
end

Options for use Chronicle.WebHooks.Webhook:

  • :target_urlrequired webhook target URL
  • :id — stable webhook identifier. Defaults to the module's last segment.
  • :event_sequence_id — optional explicit event sequence identifier

Summary

Callbacks