Repository navigation
Conversation
Each resource gets a factory on the client and in the Workflow package, which builds a handle with no call. A resource with one proto-backed record field passes as that record, so a handle can be an argument or a result.
This was referenced Oct 28, 2026
Owner
Author
|
Duplicate of #87, which has the same commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
This PR gives each Python resource a factory, and passes a resource as data.
client.stream). The Workflow package gets the same factory as a function, and exports it. It takes the definition of a resource with@nexus.definition, or its runtime types, and then the constructor fields by keyword. It makes no call. The client's handle calls through that client, and a Workflow's handle calls the operations of the code that runs it.@nexus.flatten-in-api param="stream" fields="id backend" keep=trueon a resource makes the factory take fields of one constructor parameter's record in place of the parameter. Withkeep=truethe factory also takes the whole value, soclient.stream(Turns, id="s1", backend="redis")andclient.stream(Turns, stream=ref)both work, and a call with neither or both raisesTypeError.None. A resource with a required field after an optional one is akw_onlydataclass.Stream[Turn], and the decoded handle takes the current operations. AStreamwas not data before, since the default converter tried to encodebody_type.nexgen refuses a resource flatten with a
fill, an unknown parameter, akeepthat isn'ttrueorfalse, a record that no proto backs, a required field of the record that the factory doesn't promote, and a promoted field with the name of another parameter. It also refuses a factory with the name of another client method, or of an operation function or a module of the Workflow package.The stream sample's Stream takes the flatten of Brook's next WIT. The other Python samples get their factories and the
Nonedefaults.It is for review here before it goes upstream. It sits on the upstream stack temporalio#308, temporalio#310, temporalio#311, temporalio#297, temporalio#296, temporalio#303, temporalio#304, temporalio#309, temporalio#318, temporalio#319, temporalio#320, temporalio#321, temporalio#322, temporalio#323, temporalio#324, temporalio#325, whose head is
review/p3-base, and on #77, #79, #81, #83, #86.Why?
The Stream API of the proposal has
client.stream(definition, *, id=None, stream=None, backend=None), a handle on an existing Stream, asget_workflow_handleis for a Workflow. A handle is also an Activity argument and a query result, so it must be data. The facade has its own data form and aBindQueryResultsinterceptor for this today.The design put
param=andkeep=in the field flatten PR. They are here, since only the factory reads them.TypeScript and .NET keep their constructors, which take the optional fields already, and their factories come with their client targets. .NET passes a handle in the JSON form of its properties already. Go builds a handle with a struct literal, and Java has no proto-backed models.
The factory also takes the other constructor fields, so
client.streamtakescreatedandstatustoo. A factory for a resource such asStartedWorkflowneeds all of its fields.How did you test it?
Python tests build a handle with the client factory from the id and from the ref, check
Stream[Turn]withassert_type, check that the handle calls through the client, and check the refusal of neither and both. Another test builds a handle with the Workflow factory. A round trip through the data converter checks the ref on the wire and the body type fromStream[Turn]. A generation test checks thekw_onlydataclass and the Workflow factory of a resource with a required field after an optional one. A unit test checks the keys of the resource flatten, and rejection fixtures cover each refusal.cargo validatepasses.