Reads

Reads

A read returns a stream's records in order from a position you choose, and a subscription keeps delivering new ones.

A read returns a stream's records in sequence order, starting at a position you choose. A subscription does the same, then waits at the end of the stream and delivers each new record as Nova stores it. This read asked for two records from the start of demo/events:

GET /v1/streams/demo/events/records?seq_num=0&limit=2
{
  "records": [
    {
      "seq_num": 0,
      "timestamp_ms": 1795371904303,
      "body": "hello"
    },
    {
      "seq_num": 1,
      "timestamp_ms": 1795371904303,
      "body": "world"
    }
  ],
  "bookmark": "2",
  "tail": {
    "seq_num": 5,
    "timestamp_ms": 1795372046014
  }
}

The bookmark is where the next read should start. The tail is the end of the stream when Nova replied: here three more records wait after this page.

Three ways to read

OperationWhat it returnsUse when
ReadOne page of records, then stopsYou replay history, backfill, or show "the latest ten"
SubscribeEvery record from the start position on, without endYou process records as they arrive. This is the usual choice.
Check tailOnly the tailYou need to know where the stream ends, without the records

A subscription is the same as reading page after page, so use it for any reader that keeps up with the stream. Use a read when you want a bounded answer.

Where a read starts

A read or subscription takes exactly one start:

StartBegins atUse it for
A sequence numberThat recordResuming where you stopped
A bookmarkThe place a previous response returnedResuming, on either kind of stream
A timestampThe first record at or after that timeProcessing a time window
The beginningThe oldest record still keptReplaying everything
An offset from the tailThat many records before the end"Show me the latest activity" views
The tailThe next record to arriveFollowing new records only

A read stops at the first of these: its record limit, its byte limit, an end time you give, or the tail. A page holds at most 8,192 records and 8 MiB by default, and you can ask for less. It always holds at least one record when one is there, even one larger than the byte limit. If a page stops before your limits and your end time, it reached the tail: there was nothing more to read when Nova answered.

Consistency

Reads are linearizable. Once Nova acknowledges an append, every read, subscription, and tail check that starts afterwards sees it, whichever node serves it. Records appear in order, with no gaps, and a batch appears whole or not at all.

A response's tail is the end of the stream at the moment Nova answered. Appends that come later move it on.

Subscriptions

A subscription delivers records in sequence order. Each delivery is a batch of records with the bookmark after them. If the connection breaks, the SDK reconnects and continues after the last record it delivered, so you get no gap and no repeat. It keeps trying for up to its retry budget, 30 seconds by default, counted from the first failure in a row.

Over HTTP, a subscription is a stream of server-sent events. Each event's id is the bookmark after its records:

GET /v1/streams/demo/events/records/subscribe?seq_num=2
id: 3
data: {"records":[{"seq_num":2,"timestamp_ms":1795371906316,"body":"again"}],"bookmark":"3","tail":{"seq_num":3,"timestamp_ms":1795371906316}}

To resume, reconnect with the last id in the Last-Event-ID header. Nova also sends a comment line every 15 seconds, so a proxy does not close a quiet connection. When your token expires, Nova sends an auth-expired event and closes the stream; reconnect with a new token.

A subscription ends with an error when it needs records that were trimmed, when the stream is deleted, or when the SDK's retry budget runs out.

Latency

A subscription served by the stream's leader, the node that serves its writes, gets each record as soon as Nova acknowledges it. The SDK and the Gateway connect subscriptions there. On another node, a subscription that has caught up checks again after at most 250 ms.

Recent records come from the leader's memory. Older records come from object storage, so a read of old history waits for a few object storage requests for each stored object it touches. If the leader fails, its newest acknowledged records become readable again once another node recovers them; the failure model gives the time.

Reading below the trim watermark

A read that starts before the oldest record still kept fails with 410 Gone over HTTP, OUT_OF_RANGE over gRPC. Ask the read to clamp, and it starts at the oldest record instead. Reading from the beginning does this by itself. Trimming explains the watermark.

Check the tail

A tail check returns the next sequence number and the last record's timestamp. It includes every append acknowledged before you asked. Use it after an append whose answer you never got: check the tail, read from your last known position, and look for your records before you send them again. A tail check on a stream that does not exist fails with 404.

How it works: How reads find records.

See also

On this page