-
Notifications
You must be signed in to change notification settings - Fork 20
Allow passing custom stub to execute operations #85
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
base: main
Are you sure you want to change the base?
Conversation
| class ProtoTaskHubSidecarServiceStub(object): | ||
| """A stub class roughly matching the TaskHubSidecarServiceStub generated from the .proto file. | ||
| Used by Azure Functions during orchestration and entity executions to inject custom behavior, | ||
| as no real sidecar stub is available. | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably shouldn't be mentioning Functions in durabletask docs - suggestions welcome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces support for passing custom stub implementations to worker execution methods, enabling Azure Functions to inject custom behavior where a real sidecar stub is unavailable. The key change is the addition of a ProtoTaskHubSidecarServiceStub interface class that can be used as an alternative to the gRPC-generated TaskHubSidecarServiceStub.
- Defines a new
ProtoTaskHubSidecarServiceStubclass as a protocol for custom stub implementations - Updates six worker methods to accept either the gRPC stub or the custom stub via Union type annotations
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| durabletask/internal/proto_task_hub_sidecar_service_stub.py | Introduces new stub interface class with callable attributes for all TaskHubSidecarService methods |
| durabletask/worker.py | Updates type annotations for stub parameters in _execute_orchestrator, _cancel_orchestrator, _execute_activity, _cancel_activity, _execute_entity_batch, and _cancel_entity_batch methods to accept custom stub |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Allow passing a custom stub (some implementation of the newly-defined ProtoTaskHubSidecarServiceStub) to the method call operations in the worker.
This is needed for the Azure Functions module, as the protobuf stub will not be available during worker operations - we need to be able to define and pass a custom stub with behavior to capture the inputs to the stub methods used in these methods to redirect back through the Python worker to the functions host indirectly.