FYI.Sink behaviour (FYI v1.0.2)
View SourceBehaviour for FYI notification sinks.
A sink is a destination for events (Slack, Telegram, etc.). Implement this behaviour to create custom sinks.
Example
defmodule MyApp.DiscordSink do
@behaviour FYI.Sink
@impl true
def id, do: :discord
@impl true
def init(config) do
{:ok, %{webhook_url: config.url}}
end
@impl true
def deliver(event, state) do
# POST to Discord webhook
:ok
end
end
Summary
Callbacks
Delivers an event to the sink.
Should return :ok on success or {:error, reason} on failure.
Returns the unique identifier for this sink. Used for routing configuration.
Initializes the sink with the given configuration. Called once before delivering events.
Callbacks
@callback deliver(event :: FYI.Event.t(), state :: term()) :: :ok | {:error, term()}
Delivers an event to the sink.
Should return :ok on success or {:error, reason} on failure.
@callback id() :: atom()
Returns the unique identifier for this sink. Used for routing configuration.
Initializes the sink with the given configuration. Called once before delivering events.