Skip to main content

Watch-ZrKey

Streams change notifications for a single Zaris key, emitting an event object for every change until cancelled or a limit is reached.

Syntax

Watch-ZrKey [-Key] <string> [-IncludeSnapshot] [-ConnectionString <string>] [-StoreName <string>] [-Endpoints <string[]>] [-TimeoutSec <int>]

Description

Watch-ZrKey subscribes to the connected Zaris store and continuously emits an event object for every change to the given key. It runs inline and blocks the pipeline, streaming until you press Ctrl+C (or the pipeline is otherwise cancelled); there is no built-in time or event-count limit. Specify -IncludeSnapshot to receive the key's current value as an initial event before live updates begin.

Values are deserialized automatically when possible; binary values that cannot be deserialized are returned as byte arrays. The cmdlet requires an active connection (Connect-ZrStore) or a one-shot independent connection supplied through -StoreName and -Endpoints.

Parameters

ParameterTypeRequiredDescription
-KeyStringYesThe key to watch for changes. Positional (position 0). Must not be null or empty.
-IncludeSnapshotSwitchParameterNoEmit the key's current value as an initial snapshot event before streaming live changes.
-ConnectionStringStringNoConnect via a Zaris connection string, e.g. zaris://host:7861/store; an alternative to -StoreName + -Endpoints for a one-shot connection. Ignored when a Connect-ZrStore session is active.
-StoreNameStringNoStore to operate on for a one-shot independent connection instead of the active Connect-ZrStore context. Belongs to the Independent parameter set; use together with -Endpoints.
-EndpointsString[]NoOne or more store node endpoints (host:port) for an independent connection. Only the first endpoint is used as the seed. Ignored when a Connect-ZrStore session is active.
-TimeoutSecInt32NoConnection timeout, in seconds, for an independent connection (used with -Endpoints). Range 1–120. Default 5. Does not limit how long the watch streams.

Each emitted event object has Event, Key, Revision, and Value.

Examples

Emit the current value of a key, then stream every subsequent change until Ctrl+C:

Watch-ZrKey -Key "config:featureFlags" -IncludeSnapshot

Stream live changes to a key (no initial snapshot) until Ctrl+C:

Watch-ZrKey -Key "session:user123"

Watch a key over a one-shot independent connection instead of the active session:

Watch-ZrKey -Key "leader" -ConnectionString "zaris://10.0.0.11:7861/orders"