Skip to content

[Brook K3] Added the Store trait and its capabilities. - #214

Closed
moetemp wants to merge 25 commits into
moe/brook/review/streams-k2-ids-vectorsfrom
moe/brook/review/streams-k3-store-trait
Closed

moetemp wants to merge 25 commits into
moe/brook/review/streams-k2-ids-vectorsfrom
moe/brook/review/streams-k3-store-trait

Conversation

@moetemp

@moetemp moetemp commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR adds the Store trait, the stored Record and batch limits, and the Store capabilities.

  • A Store declares what it does atomically. The service refuses a call that needs a missing one.
  • owner_chain gives a Workflow owner's run chain as <workflow id>:<first run id>. A Store keeps it and checks it on a create and a close.
  • Store::create takes one Create, with a ConflictPolicy and a request id. CreateOutcome has only Created and Exists. A Store refuses a create of a Stream that is expired, has another owner or is closed, in this order. Then a retry with the request id of the create that made the Stream gets Created, and any other create of an open Stream fails with already_exists unless its policy is UseExisting.
  • A Store's close marks the Stream closed and writes no Record. Closed says only whether the Stream was closed already.
  • MAX_TTL, the largest proto Duration, bounds a Retention and a safety TTL.
  • An append gives a batch's Records consecutive offsets that end at its last offset.

Depends on #213 (K2). Review lane is the Rust reviewers.
Part of the Brook review series.

Why?

The memory Store, the Redis Store and later a native Store implement this trait. A small PR keeps the contract apart from any one Store.

How did you test it?

cargo fmt, cargo clippy -- -D warnings (with and without features), cargo test -p temporalio-streams --all-features and cargo doc pass at this commit.

@moetemp
moetemp force-pushed the moe/brook/review/streams-k3-store-trait branch from 4a9d1b5 to 5e50e8d Compare October 27, 2026 07:35
@moetemp
moetemp force-pushed the moe/brook/review/streams-k2-ids-vectors branch from 3c800ad to f5d807e Compare October 27, 2026 08:17
@moetemp
moetemp force-pushed the moe/brook/review/streams-k3-store-trait branch from 5e50e8d to 92528cb Compare October 27, 2026 08:17
@moetemp moetemp added the skip-changelog Changelog entry rides another PR label Oct 27, 2026
@moetemp
moetemp force-pushed the moe/brook/review/streams-k3-store-trait branch from 92528cb to a6020ca Compare October 27, 2026 16:55
@moetemp
moetemp force-pushed the moe/brook/review/streams-k2-ids-vectors branch 2 times, most recently from 16de1da to bd35e0c Compare October 27, 2026 23:46
@moetemp
moetemp force-pushed the moe/brook/review/streams-k3-store-trait branch from a6020ca to 614cf9c Compare October 27, 2026 23:46
@moetemp
moetemp force-pushed the moe/brook/review/streams-k2-ids-vectors branch from bd35e0c to fe3f05a Compare October 28, 2026 08:55
@moetemp
moetemp force-pushed the moe/brook/review/streams-k3-store-trait branch from 614cf9c to 3fcf1b2 Compare October 28, 2026 08:55
A Store declares the rules it applies atomically beyond the log, and the
service refuses a call that needs a capability the Store lacks. The trait is
small so that the Redis Store and a native Store can implement it too.
@moetemp
moetemp force-pushed the moe/brook/review/streams-k2-ids-vectors branch from fe3f05a to 98ba416 Compare October 29, 2026 04:06
@moetemp
moetemp force-pushed the moe/brook/review/streams-k3-store-trait branch from 3fcf1b2 to a759d72 Compare October 29, 2026 04:06
# Conflicts:
#	crates/streams/src/lib.rs
Each Store applies its own default Retention when a create sets none.
A call with no writer state sends no sequence. Only the Store can number such a batch in the same
step as its dedupe check, so a Store declares that it does.
The batch digest is binary, so a Store gets the bytes that it keeps in the dedupe entry.
A create of an existing Stream fails unless it uses that Stream or retries the create that made it. The create's inputs are one struct, so the call stays short.
A close writes no log entry, so the state says the Stream is closed and its newest offset is final. A wait for the next entry also ends at a close.
The proto type is now StreamRef. A bare ref is a Rust keyword, so the parameter is stream_ref.
The review asked to stop representing invalid states. The Producer kind is now a oneof with run_id only in the run-based variants, so a client can't carry a run. A write's task facts and withdraw_run move into RunWithdrawal, which only a run writer sets.
@moetemp

moetemp commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Closed in favor of #228, the combined branch, which has this change.

@moetemp moetemp closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Changelog entry rides another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant