Skip to content

Conversation

@andystaples
Copy link
Contributor

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.

Comment on lines 4 to 8
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.
"""
Copy link
Contributor Author

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

Copy link
Contributor

Copilot AI left a 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 ProtoTaskHubSidecarServiceStub class 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants