-
Notifications
You must be signed in to change notification settings - Fork 1
feat: generate System Nexus interceptor points #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
42c1fb5
feat: generate System Nexus interceptor points
tconley1428 7463144
refactor: scope generation configuration
tconley1428 21c4995
refactor: read generation mode from config
tconley1428 37ecf30
refactor: configure generation at entry points
tconley1428 aa21c86
refactor: configure generation requests
tconley1428 7ebb698
refactor: configure generation requests
tconley1428 eeef5c5
test: configure generation modes explicitly
tconley1428 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
advanced/samples/python/wit/workflow_service/_system_nexus_interceptor.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # Generated by nexgen v0.2.2. DO NOT EDIT! | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
|
|
||
| import abc | ||
| import typing | ||
|
|
||
| from temporalio.nexus.system import TEMPORAL_SYSTEM_ENDPOINT | ||
|
|
||
| from . import models | ||
|
|
||
| if typing.TYPE_CHECKING: | ||
| import temporalio.workflow | ||
| from temporalio.worker._interceptor import StartNexusOperationInput | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "_start_system_nexus_operation", | ||
| "_SystemNexusWorkflowOutboundInterceptorBase", | ||
| "_SystemNexusWorkflowOutboundInterceptorTerminal", | ||
| ] | ||
|
|
||
|
|
||
| _InputT = typing.TypeVar("_InputT") | ||
| _OutputT = typing.TypeVar("_OutputT") | ||
|
|
||
|
|
||
| async def _start_system_nexus_operation( | ||
| interceptor: _SystemNexusWorkflowOutboundInterceptorBase, | ||
| input: StartNexusOperationInput[_InputT, _OutputT], | ||
| ) -> temporalio.workflow.NexusOperationHandle[_OutputT]: | ||
| if ( | ||
| input.service == "temporal.api.workflowservice.v1.WorkflowService" | ||
| and input.operation_name == "SignalWithStartWorkflowExecution" | ||
| ): | ||
| typed_input = typing.cast( | ||
| "StartNexusOperationInput[models.SignalWithStartWorkflowRequest, models.SignalWithStartWorkflowResponse]", | ||
| input, | ||
| ) | ||
| # The dispatch check above establishes that this operation's response type is _OutputT. | ||
| return typing.cast( | ||
| "temporalio.workflow.NexusOperationHandle[_OutputT]", | ||
| await interceptor.start_signal_with_start_workflow(typed_input.input), | ||
| ) | ||
| raise ValueError( | ||
| f"unsupported System Nexus operation: {input.service}/{input.operation_name}" | ||
| ) | ||
|
|
||
|
|
||
| class _SystemNexusWorkflowOutboundInterceptorBase(abc.ABC): | ||
| @abc.abstractmethod | ||
| def _next_system_nexus_interceptor( | ||
| self, | ||
| ) -> _SystemNexusWorkflowOutboundInterceptorBase: ... | ||
|
|
||
| async def start_signal_with_start_workflow( | ||
| self, request: models.SignalWithStartWorkflowRequest | ||
| ) -> temporalio.workflow.NexusOperationHandle[ | ||
| models.SignalWithStartWorkflowResponse | ||
| ]: | ||
| """Intercept the SignalWithStartWorkflow operation.""" | ||
| return await self._next_system_nexus_interceptor().start_signal_with_start_workflow( | ||
| request | ||
| ) | ||
|
|
||
|
|
||
| class _SystemNexusWorkflowOutboundInterceptorTerminal(abc.ABC): | ||
| @abc.abstractmethod | ||
| async def _outbound_start_nexus_operation( | ||
| self, | ||
| input: StartNexusOperationInput[_InputT, _OutputT], | ||
| ) -> temporalio.workflow.NexusOperationHandle[_OutputT]: ... | ||
|
|
||
| async def start_signal_with_start_workflow( | ||
| self, request: models.SignalWithStartWorkflowRequest | ||
| ) -> temporalio.workflow.NexusOperationHandle[ | ||
| models.SignalWithStartWorkflowResponse | ||
| ]: | ||
| from temporalio.worker._interceptor import StartNexusOperationInput | ||
| from temporalio.workflow import NexusOperationCancellationType | ||
|
|
||
| return await self._outbound_start_nexus_operation( | ||
| StartNexusOperationInput( | ||
| endpoint=TEMPORAL_SYSTEM_ENDPOINT, | ||
| service="temporal.api.workflowservice.v1.WorkflowService", | ||
| operation="SignalWithStartWorkflowExecution", | ||
| input=request, | ||
| output_type=models.SignalWithStartWorkflowResponse, | ||
| schedule_to_close_timeout=None, | ||
| schedule_to_start_timeout=None, | ||
| start_to_close_timeout=None, | ||
| cancellation_type=NexusOperationCancellationType.WAIT_COMPLETED, | ||
| headers=None, | ||
| summary=None, | ||
| ) | ||
| ) | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.