Something went wrong. Try again.
Sketch for an Elixir Jetstream V2 subscriber library
Something went wrong. Try again.
619 B · 27 lines · Created 1mo ago
Elixir
123456789101112131415161718192021222324252627defmodule MyApp.JetstreamLogger do use JetstreamLibrary, kinds: [] # all, collections: [] # all
require Logger
def get_cursor, do: nil def put_cursor(_seq), do: :ok
def handle_event(payload), do: Logger.info(inspect(payload))end
# add it to your application.ex
@impl true def start(_type, _args) do children = [ MyApp.JetstreamLogger, MyAppWeb.MetricsEndpoint ]
# See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: Shelf.Supervisor] Supervisor.start_link(children, opts) end