Skip to main content

watch

Function watch 

Source
pub fn watch(
    out: &mut dyn Write,
    endpoint: &Endpoint,
    args: &ScopeArgs,
    key: &str,
    inherited: bool,
    count: Option<u32>,
) -> Result<Vec<Option<Parameter>>, CliError>
Expand description

Watches one parameter, printing every value it transitions to.

Prints the value already set (if any) once at the start, then again only when a poll observes a different value than the last one printed — two consecutive polls seeing the same value print nothing, which is what makes this a change feed rather than a heartbeat. Runs until count distinct values have been observed (the initial read counts as one), or, when count is None, until interrupted (Ctrl-C/SIGTERM).

count is what makes this function callable from a test: unbounded, the only way to end it is a signal, which a deadline-polled assertion cannot wait on without racing the harness’s own signal handling. A caller that wants the production “stream forever” behaviour passes None, exactly as --watch does without --count.

§Errors

As get for the first read; a transport failure on a later poll ends the watch with that error rather than retrying forever, so a coordinator that goes away is visible rather than silently watched forever.