Streams

Streams

The routes that create, read, change, list, and delete streams.

A stream is an ordered log of records at an address, a bucket and a key. These routes manage streams themselves; the records inside them are on Records. Each route is also a method of the gRPC service nova.v1.DataPlaneService.

OperationHTTPgRPC
CreatePOST /v1/streams/{bucket}/{key}CreateStream
GetGET /v1/streams/{bucket}/{key}GetStream
ReconfigurePATCH /v1/streams/{bucket}/{key}ReconfigureStream
ListGET /v1/streams/{bucket}ListStreams
DeleteDELETE /v1/streams/{bucket}/{key}DeleteStream

The examples use the quickstart cluster's Gateway at localhost:8080 and the bucket demo. A key is one percent-encoded path segment: the key orders/eu is orders%2Feu.

The stream object

Every route that returns a stream returns this object:

{
  "stream_id": "01a20475-ebde-7ec9-9422-c12d2bc2931f",
  "bucket": "demo",
  "key": "orders",
  "kind": "plain",
  "class": "standard",
  "producer_policy": "fenced",
  "retention_max_age_ms": 86400000,
  "timestamping_mode": "client-prefer",
  "created_at_unix_ms": 1795371166686,
  "fencing_token": ""
}
stream_idstring
Nova's id for the stream, for logs and storage. No route takes it: every route names the stream by its address
bucketstring
The stream's bucket
keystring
The stream's key: 1 to 512 bytes of UTF-8, with no control characters. Nova never parses it, so / is an ordinary character
kindstring
plain, or scalable for a scalable stream
classstring
standard or express. See Storage classes
producer_policystring
any lets many writers append at once. fenced admits one at a time; see Writer coordination
retention_max_age_msinteger
Records older than this are trimmed. 0 keeps them however old
retention_max_bytesinteger
The oldest records past this size are trimmed. 0 keeps them however large the stream grows
throughput_max_bytes_per_secondinteger
The append rate. A producer past it is slowed down to it. 0 is no limit
timestamping_modestring
Whose clock stamps a record: client-prefer, client-require, or arrival. See Records
timestamping_uncappedboolean
Lets a client's stamp run past the arrival time. It cannot be combined with age retention
created_at_unix_msinteger
When the stream was created. The create response leaves it out
fencing_tokenstring
The installed fencing token, empty when there is none. Only the get route returns it

The JSON leaves out a field whose value is zero or false. So a stream without retention_max_age_ms keeps records however old.

Over gRPC the object is Stream. Its stream_id is 16 bytes, base64 in gRPC JSON. The enums are CLASS_STANDARD, CLASS_EXPRESS, PRODUCER_POLICY_ANY, PRODUCER_POLICY_FENCED, TIMESTAMPING_MODE_CLIENT_PREFER, TIMESTAMPING_MODE_CLIENT_REQUIRE, TIMESTAMPING_MODE_ARRIVAL, STREAM_KIND_PLAIN, and STREAM_KIND_SCALABLE. It also carries creation_token, and deleted_at_unix_ms once the stream is deleted.

Create a stream

POST /v1/streams/{bucket}/{key}

gRPC: DataPlaneService.CreateStream. Creates a stream in an existing bucket and returns it with 201.

classstringDefaultThe bucket's
standard or express
producer_policystringDefaultThe bucket's
any or fenced
retention_max_age_msintegerDefaultThe bucket's
Trim records older than this; 0 for no age limit
retention_max_bytesintegerDefaultThe bucket's
Trim the oldest records past this size; 0 for no size limit
throughput_max_bytes_per_secondintegerDefaultThe bucket's
Slow appends down past this rate; 0 for no limit
timestamping_modestringDefaultThe bucket's
client-prefer, client-require, or arrival
timestamping_uncappedbooleanDefaultThe bucket's
Let client stamps run past the arrival time
kindstringDefaultplain
plain or scalable
initial_rangesintegerDefault1
A scalable stream's ranges at creation, at most 256. Refused on a plain stream
creation_tokenstringDefaultNone
Makes a retried create safe: see below
curl -s -X POST localhost:8080/v1/streams/demo/orders -d '{
  "producer_policy": "fenced",
  "retention_max_age_ms": 86400000
}'
201 Created
{
  "stream_id": "01a20475-ebde-7ec9-9422-c12d2bc2931f",
  "bucket": "demo",
  "key": "orders",
  "kind": "plain",
  "class": "standard",
  "producer_policy": "fenced",
  "retention_max_age_ms": 86400000,
  "timestamping_mode": "client-prefer"
}

A field you leave out, or an enum sent as UNSPECIFIED over gRPC, is copied from the bucket's defaults when the stream is created. A later change to the bucket does not reach the stream. An empty body creates a stream with all of the bucket's defaults.

A create that times out may have created the stream. Send it again with the same creation_token, and Nova returns 201 with the stream the first attempt made. Without a token, or with another token, the retry fails with 409:

curl -s -X POST localhost:8080/v1/streams/demo/orders
409 Conflict
{
  "error": "star: create 01a20475-ec10-779d-b00c-4e2341392ae5: metadata: stream exists"
}
StatusWhenRetry
400The body is not valid JSON, or names an unknown class, policy, mode, or kindNo. Fix the request
404The bucket does not exist. Nova never creates a bucket for youAfter you create the bucket
409A stream or a queue already holds the addressOnly with the first attempt's creation_token
500A setting the node checks after the request is read: a key longer than 512 bytes or with a control character, timestamping_uncapped with age retention, more than 256 ranges, or initial_ranges on a plain stream. The node reports these as 500 todayNo. Fix the request

Express needs Express storage

A create accepts class: express even when the cluster has no Express storage. Every append to that stream then fails with 500. A reconfigure checks first and refuses with 503. Create Express streams only on a cluster that serves the class.

Get a stream

GET /v1/streams/{bucket}/{key}

gRPC: DataPlaneService.GetStream. Returns the stream object, with its created_at_unix_ms and its installed fencing_token.

curl -s localhost:8080/v1/streams/demo/orders

The response is the object at the top of this page. A writer that needs the current fencing token reads it here, without having to fail an append first.

StatusWhenRetry
404No stream at the address, or it was deletedNo

Reconfigure a stream

PATCH /v1/streams/{bucket}/{key}

gRPC: DataPlaneService.ReconfigureStream. Changes the fields the body names, and returns the stream as it now stands.

The body takes class, producer_policy, retention_max_age_ms, retention_max_bytes, throughput_max_bytes_per_second, timestamping_mode, and timestamping_uncapped. A field you leave out keeps its value. A field you send is set, zero included, so 0 returns a bound to no limit:

curl -s -X PATCH localhost:8080/v1/streams/demo/orders -d '{
  "retention_max_age_ms": 0
}'
200 OK
{
  "stream_id": "01a20475-ebde-7ec9-9422-c12d2bc2931f",
  "bucket": "demo",
  "key": "orders",
  "kind": "plain",
  "class": "standard",
  "producer_policy": "fenced",
  "timestamping_mode": "client-prefer",
  "created_at_unix_ms": 1795371166686
}

A retention change applies at once. A change to the class, the producer policy, timestamping, or throughput moves the stream to a new leader before the response, so every later append follows the new setting. A connected producer reconnects once. Records already acknowledged keep the class they were written under. The kind cannot change.

StatusWhenRetry
400An unknown value, or an enum sent as ""No. Fix the request
404No stream at the addressNo
409 with reason: queue_addressThe address holds a queue. Change it with the queue routesNo
503A class this cluster does not serve, or the leader is movingNot for the class. Otherwise, after Retry-After

The stream's leader serves the change. Over gRPC, StreamReconfiguration marks every field optional, so an absent field stays as it is. An enum must name a value; UNSPECIFIED is refused with InvalidArgument. Another node answers FailedPrecondition with NotOwner. Reconfiguring needs the create grant on the address.

List a bucket's streams

GET /v1/streams/{bucket}

gRPC: DataPlaneService.ListStreams. Returns one page of a bucket's streams.

key_prefixstringDefaultNone
Only streams whose key starts with this
limitintegerDefault1,000
The most streams on the page, at most 1,000
start_afterstringDefaultNone
The next of the page before
curl -s 'localhost:8080/v1/streams/demo?limit=2'
200 OK
{
  "streams": [
    {
      "stream_id": "01a20475-ec38-73dc-9df7-cdf7111475dd",
      "bucket": "demo",
      "key": "clicks",
      "kind": "scalable",
      "class": "standard",
      "producer_policy": "any",
      "timestamping_mode": "client-prefer",
      "created_at_unix_ms": 1795371166776
    },
    {
      "stream_id": "01a20475-ec76-727c-b0ae-9eb3c4990ec0",
      "bucket": "demo",
      "key": "events",
      "kind": "plain",
      "class": "standard",
      "producer_policy": "any",
      "timestamping_mode": "client-prefer",
      "created_at_unix_ms": 1795371166838
    }
  ],
  "next": "AaIEdex2cnywrp6zxJkOwA"
}

Pass next as start_after to read the following page. A response without next is the last page. The cursor is opaque. With key_prefix, the response also returns the prefix it applied as key_prefix. A listing never includes fencing_token, and covers one bucket only.

StatusWhenRetry
400A start_after that is not a cursor, or a bad prefixNo
403The token's list grant does not cover every key the prefix namesNo

Over gRPC, bucket is required. A response with an empty key_prefix to a request that sent one comes from a server too old to filter.

Delete a stream

DELETE /v1/streams/{bucket}/{key}

gRPC: DataPlaneService.DeleteStream. Deletes the stream and returns 204. Nova reclaims its storage later, in the background.

curl -s -X DELETE localhost:8080/v1/streams/demo/events

Deleting is safe to retry: a second delete of the same stream also returns 204. A new stream created at the address starts empty, with a new stream_id.

StatusWhenRetry
404No stream ever existed at the addressNo
409 with reason: queue_addressThe address holds a queue. Use the queue's deleteNo
503The leader is movingYes, after Retry-After

The stream's leader serves the delete. Deleting needs the delete grant, which is separate from trim. A deleted stream still counts against its bucket for a few minutes, until Nova has reclaimed its storage, so a bucket delete right after it is refused. The same call is Delete a stream in the SDKs and nova stream delete in the CLI. Statuses every route shares are on Errors.

On this page