View Source migraterl_listener (migraterl v0.5.0)

Opt-in reactive layer over Postgres LISTEN/NOTIFY.

Holds a single dedicated connection that LISTENs on the migraterl events channel and fans each notification out to subscribed processes. Because NOTIFY fires on commit and the emitting run writes the journal row in the same transaction, the journal is the durable record of truth and each event is only a hint that something changed.

Subscribers receive {migraterl_event, Channel, Payload}, where Channel and Payload are binaries.

Summary

Functions

Start a listener with the given epgsql connect config map.

Subscribe the calling process to migration events.

Functions

handle_call/3

handle_cast(Msg, State)

handle_info/2

init(ConnConfig)

start_link(ConnConfig)

-spec start_link(map()) -> {ok, pid()} | {error, term()}.

Start a listener with the given epgsql connect config map.

subscribe(Listener)

-spec subscribe(pid()) -> ok.

Subscribe the calling process to migration events.

subscribe(Listener, Pid)

-spec subscribe(pid(), pid()) -> ok.

terminate/2

unsubscribe(Listener, Pid)

-spec unsubscribe(pid(), pid()) -> ok.