-
Notifications
You must be signed in to change notification settings - Fork 20
Andystaples/add functions support #75
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
Draft
andystaples
wants to merge
5
commits into
main
Choose a base branch
from
andystaples/add-functions-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7ff1525
Storing changes commit
andystaples 552a2dd
Working orchestrators + activities
andystaples af0e3c2
Nitpicks and cleanup
andystaples 86ee081
Merge branch 'main' into andystaples/add-functions-support
andystaples 3497148
Save-all nits
andystaples 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
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,10 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## v0.1.0 | ||
|
|
||
| - Initial implementation |
Empty file.
2 changes: 2 additions & 0 deletions
2
durabletask-azurefunctions/durabletask/azurefunctions/__init__.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,2 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. |
85 changes: 85 additions & 0 deletions
85
durabletask-azurefunctions/durabletask/azurefunctions/client.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,85 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| import json | ||
|
|
||
| from datetime import timedelta | ||
| from typing import Any, Optional | ||
| import azure.functions as func | ||
|
|
||
| from durabletask.entities import EntityInstanceId | ||
| from durabletask.client import TaskHubGrpcClient | ||
| from durabletask.azurefunctions.internal.azurefunctions_grpc_interceptor import AzureFunctionsDefaultClientInterceptorImpl | ||
|
|
||
|
|
||
| # Client class used for Durable Functions | ||
| class DurableFunctionsClient(TaskHubGrpcClient): | ||
| taskHubName: str | ||
| connectionName: str | ||
| creationUrls: dict[str, str] | ||
| managementUrls: dict[str, str] | ||
| baseUrl: str | ||
| requiredQueryStringParameters: str | ||
| rpcBaseUrl: str | ||
| httpBaseUrl: str | ||
| maxGrpcMessageSizeInBytes: int | ||
| grpcHttpClientTimeout: timedelta | ||
|
|
||
| def __init__(self, client_as_string: str): | ||
| client = json.loads(client_as_string) | ||
|
|
||
| self.taskHubName = client.get("taskHubName", "") | ||
| self.connectionName = client.get("connectionName", "") | ||
| self.creationUrls = client.get("creationUrls", {}) | ||
| self.managementUrls = client.get("managementUrls", {}) | ||
| self.baseUrl = client.get("baseUrl", "") | ||
| self.requiredQueryStringParameters = client.get("requiredQueryStringParameters", "") | ||
| self.rpcBaseUrl = client.get("rpcBaseUrl", "") | ||
| self.httpBaseUrl = client.get("httpBaseUrl", "") | ||
| self.maxGrpcMessageSizeInBytes = client.get("maxGrpcMessageSizeInBytes", 0) | ||
| # TODO: convert the string value back to timedelta - annoying regex? | ||
| self.grpcHttpClientTimeout = client.get("grpcHttpClientTimeout", timedelta(seconds=30)) | ||
andystaples marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| interceptors = [AzureFunctionsDefaultClientInterceptorImpl(self.taskHubName, self.requiredQueryStringParameters)] | ||
|
|
||
| # We pass in None for the metadata so we don't construct an additional interceptor in the parent class | ||
| # Since the parent class doesn't use anything metadata for anything else, we can set it as None | ||
| super().__init__( | ||
| host_address=self.rpcBaseUrl, | ||
| secure_channel=False, | ||
| metadata=None, | ||
| interceptors=interceptors) | ||
|
|
||
| def create_check_status_response(self, request: func.HttpRequest, instance_id: str) -> func.HttpResponse: | ||
| """Creates an HTTP response for checking the status of a Durable Function instance. | ||
|
|
||
| Args: | ||
| request (func.HttpRequest): The incoming HTTP request. | ||
| instance_id (str): The ID of the Durable Function instance. | ||
| """ | ||
| raise NotImplementedError("This method is not implemented yet.") | ||
|
|
||
| def create_http_management_payload(self, instance_id: str) -> dict[str, str]: | ||
|
||
| """Creates an HTTP management payload for a Durable Function instance. | ||
|
|
||
| Args: | ||
| instance_id (str): The ID of the Durable Function instance. | ||
| """ | ||
| raise NotImplementedError("This method is not implemented yet.") | ||
|
|
||
| def read_entity_state( | ||
| self, | ||
| entity_id: EntityInstanceId, | ||
| task_hub_name: Optional[str], | ||
| connection_name: Optional[str] | ||
| ) -> tuple[bool, Any]: | ||
| """Reads the state of a Durable Entity. | ||
|
|
||
| Args: | ||
| entity_id (str): The ID of the Durable Entity. | ||
| task_hub_name (Optional[str]): The name of the task hub. | ||
| connection_name (Optional[str]): The name of the connection. | ||
|
|
||
| Returns: | ||
| (bool, Any): A tuple containing a boolean indicating if the entity exists and its state. | ||
| """ | ||
| raise NotImplementedError("This method is not implemented yet.") | ||
13 changes: 13 additions & 0 deletions
13
durabletask-azurefunctions/durabletask/azurefunctions/constants.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,13 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| """Constants used to determine the local running context.""" | ||
andystaples marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # TODO: Remove unused constants after module is complete | ||
| DEFAULT_LOCAL_HOST: str = 'localhost:7071' | ||
| DEFAULT_LOCAL_ORIGIN: str = f'http://{DEFAULT_LOCAL_HOST}' | ||
| DATETIME_STRING_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ' | ||
| HTTP_ACTION_NAME = 'BuiltIn::HttpActivity' | ||
| ORCHESTRATION_TRIGGER = "orchestrationTrigger" | ||
| ACTIVITY_TRIGGER = "activityTrigger" | ||
| ENTITY_TRIGGER = "entityTrigger" | ||
| DURABLE_CLIENT = "durableClient" | ||
11 changes: 11 additions & 0 deletions
11
durabletask-azurefunctions/durabletask/azurefunctions/decorators/__init__.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,11 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| """Durable Task SDK for Python entities component""" | ||
|
|
||
| import durabletask.azurefunctions.decorators.durable_app as durable_app | ||
| import durabletask.azurefunctions.decorators.metadata as metadata | ||
|
|
||
| __all__ = ["durable_app", "metadata"] | ||
|
|
||
| PACKAGE_NAME = "durabletask.azurefunctions.decorators" |
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.
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.
[nitpick] Potential compatibility issue with type hint syntax. The use of
dict[str, str](PEP 585 style) requires Python 3.9+. Whilepyproject.tomlspecifiesrequires-python = ">=3.9", consider whether this is the intended minimum version or ifDict[str, str]fromtypingshould be used for broader compatibility.