Skip to content

feat: support stream configuration during on-demand stream creation - #130

Merged
quettabit merged 2 commits into
mainfrom
m/stream-config-header
Sep 17, 2026
Merged

quettabit merged 2 commits into
mainfrom
m/stream-config-header

Conversation

@infiniteregrets

Copy link
Copy Markdown
Member

Adds stream_config to AppendInput and as a keyword argument on read, read_session, append_session, and producer. It is JSON-encoded and sent as the s2-stream-config header; the server applies it over the basin's default stream configuration only when the append or read auto-creates the stream, and ignores it if the stream already exists. Sessions resend it on every connect. Same shape as the Rust SDK (stream_config), s2-sdk-go#385, and s2-sdk-typescript#358.

config = StreamConfig(retention_policy=3600)

await stream.append(AppendInput(records=[...], stream_config=config))
await stream.read(start=SeqNum(0), stream_config=config)
async with stream.append_session(stream_config=config) as session: ...
async with stream.read_session(start=SeqNum(0), stream_config=config) as session: ...

Server side: s2-streamstore/s2#718, s2-streamstore/s2-cloud#1767.

@infiniteregrets
infiniteregrets requested a review from a team as a code owner September 13, 2026 00:05
@greptile-apps

greptile-apps Bot commented Sep 13, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the new option is consistently propagated across supported operations and remains compatible with the shared SDK contract.

Summary

This PR adds optional stream configuration for streams created on demand through unary and session-based append/read operations.

  • Encodes StreamConfig as the s2-stream-config request header.
  • Propagates configuration through append sessions, read sessions, and producers, including reconnects.
  • Adds end-to-end coverage for inheritance from basin defaults and behavior with existing streams.
  • Documents the new API with an example.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    C[Caller supplies StreamConfig] --> E[Encode configuration as JSON]
    E --> H[s2-stream-config header]
    H --> U[Unary append or read]
    H --> S[Append or read session]
    S --> R[Resend header on reconnect]
    U --> A{Stream exists?}
    R --> A
    A -->|No| M[Merge with basin defaults and create stream]
    A -->|Yes| I[Ignore supplied configuration]
Loading

Reviews (2) · Last reviewed commit: "integration test instead of mock"

@quettabit quettabit changed the title feat: s2-stream-config header support feat: support stream configuration during on-demand stream creation Sep 17, 2026
@quettabit
quettabit merged commit c0aa081 into main Sep 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants