Loading...
Searching...
No Matches
KeyValue store watcher
Functions » KeyValue store

## Functions

NATS_EXTERN natsStatus | kvWatcher_Next (kvEntry **new_entry, kvWatcher *w, int64_t timeout)
| Returns the next entry for this watcher.
NATS_EXTERN natsStatus | kvWatcher_Stop (kvWatcher *w)
| Stops the watcher.
NATS_EXTERN void | kvWatcher_Destroy (kvWatcher *w)
| Destroys the KeyValue watcher object.

## Detailed Description

These functions allow to receive updates for key(s) on a given bucket.

Warning
  EXPERIMENTAL FEATURE! We reserve the right to change the API without necessarily bumping the major version of the library.

## Function Documentation

## kvWatcher_Next()

NATS_EXTERN natsStatus kvWatcher_Next | ( | kvEntry ** | new_entry,
|  | kvWatcher * | w,
|  | int64_t | timeout
| ) |  |

Returns the next entry for this watcher. The entry may be `NULL` (with NATS_OK status) to indicate that the initial state has been retrieved.

If a thread is waiting on this call, it can be canceled with a call to kvWatcher_Stop.

Note
  The entry should be destroyed to release memory using kvEntry_Destroy.

Parameters

  new_entry | the location where to store the pointer to the kvEntry object.
  w | the pointer to the kvWatcher object.
  timeout | how long to wait (in milliseconds) for the next entry.

## kvWatcher_Stop()

NATS_EXTERN natsStatus kvWatcher_Stop | ( | kvWatcher * | w | ) |

Stops the watcher. Stopping a stopped watcher returns NATS_OK.

After this call, new and existing calls to kvWatcher_Next (that are waiting for an update) will return with NATS_ILLEGAL_STATE.

Parameters

  w | the pointer to the kvWatcher object.

## kvWatcher_Destroy()

NATS_EXTERN void kvWatcher_Destroy | ( | kvWatcher * | w | ) |

Releases memory allocated for this kvWatcher object.

Parameters

  w | the pointer to the kvWatcher object.