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

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

Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for GenServer.init/1.

Types

keywatch_handler()

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

watcher_options()

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

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

init(opts)

Callback implementation for GenServer.init/1.

start_link(opts)

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

stop(pid)