-
Notifications
You must be signed in to change notification settings - Fork 77
Support configurable workflow gRPC payload limits for agents and orchestrators #250
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
+255
−0
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0a26918
feat(grpc): add workflow gRPC options model and helper
Cyb3rWard0g 2912cf2
refactor(components): plumb workflow gRPC options through bases
Cyb3rWard0g cd1ca40
feat(workflows): honor gRPC limits in durable agents & orchestrators
Cyb3rWard0g 389821d
test(grpc): cover durabletask channel patching helper
Cyb3rWard0g 1d3ccb1
Basic quickstart to show how to use the new config
Cyb3rWard0g 1097b9c
Make lint happy
Cyb3rWard0g c140ab4
refactor: Clarify gRPC options check to explicitly support setting ei…
Cyb3rWard0g ae03ee9
docs: Add reference to original durabletask get_grpc_channel implemen…
Cyb3rWard0g c18fa6f
fix: address merge conflict so we can merge
sicoyle 975d111
fix: rm extra quickstart used for testing
sicoyle 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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,89 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from typing import Optional, Sequence | ||
|
|
||
| from dapr_agents.agents.configs import WorkflowGrpcOptions | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| # This is a copy of the original get_grpc_channel function in durabletask.internal.shared at | ||
| # https://github.com/dapr/durabletask-python/blob/7070cb07d07978d079f8c099743ee4a66ae70e05/durabletask/internal/shared.py#L30C1-L61C19 | ||
| # but with my option overrides applied above. | ||
| def apply_grpc_options(options: Optional[WorkflowGrpcOptions]) -> None: | ||
| """ | ||
| Patch Durable Task's gRPC channel factory with custom message size limits. | ||
| Durable Task (and therefore Dapr Workflows) creates its gRPC channels via | ||
| ``durabletask.internal.shared.get_grpc_channel``. This helper monkey patches | ||
| that factory so that subsequent runtime/client instances honour the provided | ||
| ``grpc.max_send_message_length`` / ``grpc.max_receive_message_length`` values. | ||
| Users can set either or both options; any non-None value will be applied. | ||
| """ | ||
| if not options: | ||
| return | ||
| # Early return if neither option is set | ||
| if ( | ||
| options.max_send_message_length is None | ||
| and options.max_receive_message_length is None | ||
| ): | ||
| return | ||
|
|
||
| try: | ||
| import grpc | ||
| from durabletask.internal import shared | ||
| except ImportError as exc: | ||
| logger.error( | ||
| "Failed to import grpc/durabletask for channel configuration: %s", exc | ||
| ) | ||
| raise | ||
|
|
||
| grpc_options = [] | ||
| if options.max_send_message_length: | ||
| grpc_options.append( | ||
| ("grpc.max_send_message_length", options.max_send_message_length) | ||
| ) | ||
| if options.max_receive_message_length: | ||
| grpc_options.append( | ||
| ("grpc.max_receive_message_length", options.max_receive_message_length) | ||
| ) | ||
|
|
||
| def get_grpc_channel_with_options( | ||
| host_address: Optional[str], | ||
| secure_channel: bool = False, | ||
| interceptors: Optional[Sequence["grpc.ClientInterceptor"]] = None, | ||
| ): | ||
| if host_address is None: | ||
| host_address = shared.get_default_host_address() | ||
|
|
||
| for protocol in getattr(shared, "SECURE_PROTOCOLS", []): | ||
| if host_address.lower().startswith(protocol): | ||
| secure_channel = True | ||
| host_address = host_address[len(protocol) :] | ||
| break | ||
|
|
||
| for protocol in getattr(shared, "INSECURE_PROTOCOLS", []): | ||
| if host_address.lower().startswith(protocol): | ||
| secure_channel = False | ||
| host_address = host_address[len(protocol) :] | ||
| break | ||
|
|
||
| if secure_channel: | ||
| credentials = grpc.ssl_channel_credentials() | ||
| channel = grpc.secure_channel( | ||
| host_address, credentials, options=grpc_options | ||
| ) | ||
| else: | ||
| channel = grpc.insecure_channel(host_address, options=grpc_options) | ||
|
|
||
| if interceptors: | ||
| channel = grpc.intercept_channel(channel, *interceptors) | ||
|
|
||
| return channel | ||
|
|
||
| shared.get_grpc_channel = get_grpc_channel_with_options | ||
| logger.debug( | ||
| "Applied gRPC options to durabletask channel factory: %s", dict(grpc_options) | ||
| ) | ||
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.