Module eetcd_watch

Data Types

watch_conn()

watch_conn() = #{http2_pid => pid(), monitor_ref => reference(), stream_ref => reference(), unprocessed => binary(), revision => integer(), compact_revision => integer(), watch_id => integer(), response => router_pb:'Etcd.WatchResponse'()}

Function Index

new/0init watch request.
rev/1Rev returns the current revision of the KV the stream watches on.
unwatch/2 Cancel watching so that no more events are transmitted.
watch/2@equiv watch(name(), context(), 5000).
watch/3Watch watches for events happening or that have happened.
watch_stream/2Streams the next batch of events from the given message.
with_filter_delete/1discards DELETE events from the watcher.
with_filter_put/1discards PUT events from the watcher.
with_fragment/1WithFragment to receive raw watch response with fragmentation.
with_from_key/1Specifies the range of get, delete requests to be equal or greater than the key in the argument.
with_key/2Sets the byte slice for the Op's key.
with_prefix/1Enables watch requests to operate on the keys with matching prefix.
with_prev_kv/1Get the previous key-value pair before the event happens.
with_progress_notify/1Make watch server send periodic progress updates every 10 minutes when there is no incoming events.
with_range_end/2Sets the byte slice for the Op's range_end.
with_start_revision/2
with_watch_id/2AutoWatchID is the watcher ID passed in WatchStream.Watch when no user-provided ID is available, an ID will automatically be assigned.

Function Details

new/0

new() -> context()

init watch request

rev/1

rev(X1) -> any()

Rev returns the current revision of the KV the stream watches on.

unwatch/2

unwatch(WatchConn::watch_conn(), Timeout) -> {ok, router_pb:'Etcd.WatchResponse'(), OtherEvents} | {error, {stream_error | conn_error | http2_down, term()} | timeout, OtherEvents}

Cancel watching so that no more events are transmitted. This is a synchronous operation. Other change events will be returned in OtherEvents when these events arrive between the request and the response.

watch/2

watch(Name::name(), CreateReq::context()) -> {ok, watch_conn()} | {error, {stream_error | conn_error | http2_down, term()} | timeout}

@equiv watch(name(), context(), 5000).

watch/3

watch(Name::name(), CreateReq::context(), Timeout::pos_integer()) -> {ok, watch_conn()} | {error, {stream_error | conn_error | http2_down, term()} | timeout}

Watch watches for events happening or that have happened. Both input and output are streams; the input stream is for creating watchers and the output stream sends events. One watch RPC can watch on multiple key ranges, streaming events for several watches at once. The entire event history can be watched starting from the last compaction revision.

Watch creates a watcher. The watcher watches the events happening or happened on the given key or range [key, end) from the given startRev.

The whole event history can be watched unless compacted. If startRev <= 0, watch observes events after currentRev.

The returned "id" is the ID of this watcher. It appears as WatchID in events that are sent to the created watcher through stream channel.

watch_stream/2

watch_stream(Conn::watch_conn(), Message) -> {ok, watch_conn(), router_pb:'Etcd.WatchResponse'()} | {more, watch_conn()} | unknown | {error, {stream_error | conn_error | http2_down, term()}}

Streams the next batch of events from the given message. This function processes a "message" which can be any term, but should be a message received by the process that owns the stream_ref. Processing a message means that this function will parse it and check if it's a message that is directed to this connection, that is, a gun_* message received on the gun connection. If it is, then this function will parse the message, turn it into watch responses, and possibly take action given the responses. If there's no error, this function returns {ok, WatchConn, 'Etcd.WatchResponse'()}|{more, WatchConn} If there's an error, {error, {stream_error | conn_error | http2_down, term()} | timeout} is returned. If the given message is not from the gun connection, this function returns unknown.

with_filter_delete/1

with_filter_delete(Context::context()) -> context()

discards DELETE events from the watcher.

with_filter_put/1

with_filter_put(Context::context()) -> context()

discards PUT events from the watcher.

with_fragment/1

with_fragment(Context::context()) -> context()

WithFragment to receive raw watch response with fragmentation. Fragmentation is disabled by default. If fragmentation is enabled, etcd watch server will split watch response before sending to clients when the total size of watch events exceed server-side request limit. The default server-side request limit is 1.5 MiB, which can be configured as "--max-request-bytes" flag value + gRPC-overhead 512 bytes.

with_from_key/1

with_from_key(Context::context()) -> context()

Specifies the range of get, delete requests to be equal or greater than the key in the argument.

with_key/2

with_key(Context::context(), Key::key()) -> context()

Sets the byte slice for the Op's key.

with_prefix/1

with_prefix(Context::context()) -> context()

Enables watch requests to operate on the keys with matching prefix. For example, watch("foo", with_prefix()) can return 'foo1', 'foo2', and so on.

with_prev_kv/1

with_prev_kv(Context::context()) -> context()

Get the previous key-value pair before the event happens. If the previous KV is already compacted, nothing will be returned.

with_progress_notify/1

with_progress_notify(Context::context()) -> context()

Make watch server send periodic progress updates every 10 minutes when there is no incoming events. Progress updates have zero events in WatchResponse.

with_range_end/2

with_range_end(Context::context(), End::iodata()) -> context()

Sets the byte slice for the Op's range_end.

with_start_revision/2

with_start_revision(Context, Rev) -> any()

with_watch_id/2

with_watch_id(Context, WatchId) -> any()

AutoWatchID is the watcher ID passed in WatchStream.Watch when no user-provided ID is available, an ID will automatically be assigned.


Generated by EDoc