View Source Gnat.Jetstream.API.KV.Watcher (gnat v1.8.3)

The watcher server establishes a subscription to the changes that occur to a given key-value bucket. The consumer-supplied handler function will be sent an indicator as to whether the change is a delete or an add, as well as the key being changed and the value (if it was added).

Ensure that you call stop with a watcher pid when you no longer need to be notified about key changes

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for GenServer.init/1.

Link to this section Types

Specs

keywatch_handler() ::
  (action :: :key_deleted | :key_added, key :: String.t(), value :: any() ->
     nil)

Specs

watcher_options() ::
  {:conn, Gnat.t()}
  | {:bucket_name, String.t()}
  | {:handler, keywatch_handler()}

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Callback implementation for GenServer.init/1.

Specs

start_link(opts :: [watcher_options()]) :: GenServer.on_start()