Repository navigation
Conversation
bf635e6 to
bba27f4
Compare
953a9d8 to
779ab52
Compare
| data in an activation must fit within 1 MiB. Keep messages short to avoid | ||
| failing the Workflow Task with ``StreamMarkerTooLarge``. | ||
|
|
||
| Calls can run concurrently on the event loop. Cancellation can follow a |
There was a problem hiding this comment.
Express just the thing the user needs: their methods should be concurrency safe.
| Calls can run concurrently on the event loop. Cancellation can follow a | ||
| timeout, eviction or Worker shutdown. A cancelled call may have taken effect. | ||
| The Store must remain usable, and overlapping retries must not duplicate a | ||
| batch. |
There was a problem hiding this comment.
This paragraph doesn't seem to get the point across: your methods may be called multiple times with the same batch so it should be idempotent, I don't think cancel is really relevant.
| @@ -0,0 +1,257 @@ | |||
| """Stream Stores and the Stream config of a client.""" | |||
There was a problem hiding this comment.
Probably makes sense to have its own module. temporalio.streams
| Methods use request and response messages from | ||
| :py:mod:`temporalio.api.streamservice.v1`. Requests contain a Stream id. | ||
| The SDK routes each ``StreamRef`` to its registered Store and sets the Store | ||
| name on refs returned by create. Stores don't read or set ``StreamRef.store``. |
There was a problem hiding this comment.
Why mention streamref at all?
|
|
||
| Retention: | ||
|
|
||
| * Retention starts at create and restarts after an append that writes a batch. |
There was a problem hiding this comment.
"The retention timer" perhaps?
| Retention: | ||
|
|
||
| * Retention starts at create and restarts after an append that writes a batch. | ||
| Retries and reads don't extend it. The Store sets the retention period. |
There was a problem hiding this comment.
Retries? Of what? A retried write doesn't?
| Retention: | ||
|
|
||
| * Retention starts at create and restarts after an append that writes a batch. | ||
| Retries and reads don't extend it. The Store sets the retention period. |
There was a problem hiding this comment.
I don't see the store setting a retention period, what does that mean?
| The Store must remain usable, and overlapping retries must not duplicate a | ||
| batch. | ||
|
|
||
| SDK Core validates and retries Workflow appends and reads during outages. |
There was a problem hiding this comment.
We shouldn't mention sdk core by name
779ab52 to
0f600a2
Compare
b4e3098 to
8661820
Compare
`datetime.fromtimestamp(0)` reads the local time zone, so on a host west of UTC the default times of `ActivityEnvironment` fall before 1970. SDK Core and the client both refuse a Stream append whose Producer has an attempt time before 1970.
A Store is the service that keeps the Records of a Stream. The contract says what client, Activity and Workflow calls need from a Store, and `StreamConfig` registers the Stores of a client and its Workers.
Tests and local runs need a Store with no other service. The memory Store keeps its Streams in plain Python data and applies the rules of `StreamStore` in their order, so it also shows what a Store does.
An Activity that appends each model token pays one Store call for each token. The appender batches them with one write in flight, and stops at the first failed batch so that a reader sees no gap. `current_producer` and `as_producer` let resumed Activity work write as its first Producer.
Store names are required to stay stable. A second registry is not needed to protect against changing them.
The docstrings say the same in fewer words. No code changes.
Explain Stores, Producers, attempts, request ids, fencing and offsets once in the temporalio.streams module docs, so the Store rules can say why each rule exists. Rewrite the appender, Producer and memory Store docs in active voice. Only docstrings, comments and the README change.
8b27ffe to
9ec5040
Compare
What was changed
temporalio.streamsgets the Store contract, and the SDK gets an in-memory Store, Producer helpers and a buffered appender.Why?
Anyone can write a Store, so the contract spells out what the SDK relies on: safe concurrent calls, all-or-nothing batches, offsets that only grow, and how long to keep Records for replay. Each Store picks its retention and decides whether to fence older attempts. A Store that remembers a resend answers it with the first offsets, so a retry never writes the Records twice.
The contract uses the protobuf requests and responses. Whether to generate the Store interface is still open.
Reviewer's guide
Review after #2128.
temporalio/streams.pyfor the contract and what each method must do.temporalio/testing/_stream_store.pyagainst it. One instance serves one event loop.temporalio/contrib/streams/_appender.pyfor how it flushes and fails, then the Producer helpers.Checklist