Read plans

Read plans

The gRPC call that names the objects in storage holding a stream's older records, so a reader can fetch them itself.

A read plan lists the objects in storage that hold a stream's older records. A reader with a plan fetches those bytes from object storage itself, so reading history costs the nodes nothing. The call is gRPC only, a method of nova.v1.DataPlaneService. The Gateway uses plans to serve history; the SDKs do not. Most callers never need one: read returns the same records.

Get a read plan

gRPC: DataPlaneService.ReadPlan. Returns the stream objects that hold a stream's records from a start, and the sequence number where the plan stops. Any node answers, so the call does not need the stream's leader.

Request fieldTypeDefaultMeaning
bucket, keystringRequiredThe stream
seq_numintegerNoneStart at the record with this sequence number. Send this or timestamp_ms
timestamp_msintegerNoneStart at the first record stamped at or after this time
limitinteger256The most entries, cut to the node's limit, 256. At least one is returned
clampbooleanfalseStart a plan below the trim watermark at the first stored record. Without it, such a plan fails with OUT_OF_RANGE

There is no tail_offset: to plan from N records before the tail, check the tail first.

grpcurl -plaintext -import-path proto -proto nova/v1/dataplane.proto -d '{
  "bucket": "demo",
  "key": "events",
  "seq_num": 0
}' \
  localhost:7781 nova.v1.DataPlaneService/ReadPlan
{
  "entries": [
    {
      "url": "mem://streams/demo/01a204f2-d52b-7687-abbf-c500b962b65b/1/00000000000000000000?ttl=5m0s",
      "footerOff": "18",
      "footerLen": "159",
      "payloadBytes": "15",
      "minTimestampMs": "1795379352914",
      "maxTimestampMs": "1795379352914"
    }
  ],
  "vendedUntil": "3",
  "expiresAtUnixMs": "1795379683741"
}

This response came from a node that kept its objects in memory, so the URL is a mem:// one. A node on S3 or RustFS returns a presigned HTTP URL. gRPC JSON leaves out fields that are zero, so the entry's first_seq_num, 0, is absent. The stream held three records, all in this one object, so the plan covers sequence numbers 0 to 2 and stops at 3.

Response fieldMeaning
entriesOne per stream object, in order. Each entry's records end where the next entry's begin, and the last ends at vended_until
entries[].urlA presigned URL for the whole object, valid until expires_at_unix_ms. Send your own Range headers. Nodes return this by default (novad --readplan-vending presigned)
entries[].objectstorage_bucket and object_key, for a reader that fetches with its own storage credentials. Nodes return this with novad --readplan-vending raw
entries[].footer_off, footer_lenThe byte range of the object's directory, which says where each record is
entries[].payload_bytesThe object's data bytes, for sizing the fetch
entries[].first_seq_numThe sequence number of the object's first record
entries[].min_timestamp_ms, max_timestamp_msThe times of the object's records. A timestamp_ms start picks an entry by these, and the reader finds the record in its directory
vended_untilThe first sequence number the plan does not cover. From there on, use read or subscribe. Absent when a timestamp_ms start is past every stream object: read from that same time
moreThe plan stopped at its entry limit: ask again from vended_until
expires_at_unix_msWhen the plan stops being valid: half the auditor's read grace after the call, 5 minutes by default. Zero when the plan has no entries
StatusWhenRetry
NOT_FOUNDNo stream at the address. A plan never creates oneNo
OUT_OF_RANGEThe start is below the trim watermarkWith clamp: true
PERMISSION_DENIEDThe token has no read grant on the streamNo
UNIMPLEMENTEDThe node keeps its data on local disk (novad --local-data) and makes no plansNo. Use read

Read with a plan

  1. Ask for a plan from your start.
  2. For each entry, fetch the directory at footer_off and footer_len, then fetch only the byte ranges of the records you need. The stream object format describes the directory.
  3. When more is true, ask for the next plan from vended_until.
  4. From vended_until on, read or subscribe through a node as usual.
  5. Finish each fetch before expires_at_unix_ms, or ask for a new plan.

A plan covers only records that Nova has already copied into stream objects, so it never holds the newest records. Those wait in shared objects for up to 24 hours on Standard and 1 hour on Express, and a node serves them. A fresh stream's plan has no entries:

{
  "vendedUntil": "0"
}

An out-of-date plan is still correct, and every object a valid plan names still exists: Nova deletes an object only once the read grace has passed since its last reference, twice a plan's lifetime. On a scalable stream a plan names no range and vends nothing, so read it through a node. A plan needs the same read grant as a read.

On this page