Skip to main content

Streaming

Ionflow allows clients to track changes to resources through the use of a watch mechanism. This allows a client to fetch the current state of a resource and then subscribe to subsequent changes, without missing any events.

To use the watch mechanism in Ionflow, a client first makes a request for a list or get of a resource or collection of resources. The response from the API server includes a resourceVersion field, which represents the version of the resource as stored in the underlying persistence layer. The client can then use this resourceVersion to initiate a watch request against the API server.

The watch request returns a stream of changes that itemize the outcome of operations (such as create, delete, and update) that occurred after the specified resourceVersion. If a client watch is disconnected, it can start a new watch from the last returned resourceVersion or perform a fresh get or list request and begin again.

Example

Here is an example of using the ionflow row file watch command with resource versions:

  1. First, list all files in a given row:
ionflow row file list <row_id>
  1. The response from the command will include a resourceVersion value. For example: A1
  2. Use the resourceVersion value to initiate a watch against the Ionflow server
ionflow row file watch -r <row_id> -n A1
  1. The Ionflow server will respond with a stream of changes. These changes itemize the outcome of operations (such as create, delete, and update) that occurred after the resourceVersion you specified as a parameter to the watch request. The overall watch mechanism allows a client to fetch the current state and then subscribe to subsequent changes, without missing any events. For example:
{
"type": "ADDED",
"object": {"kind": "File", "apiVersion": "v1", "metadata": {"resourceVersion": "A2", ...}, ...}
}
{
"type": "MODIFIED",
"object": {"kind": "File", "apiVersion": "v1", "metadata": {"resourceVersion": "A3", ...}, ...}
}
...

!!! tip If the client watch is disconnected, the client can start a new watch from the last returned resourceVersion. The client could also perform a fresh list request and begin again.