Skip to content
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

fix: Http V2 route params update #1491

Merged
merged 6 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure_functions_worker/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
SHARED_MEMORY_DATA_TRANSFER = "SharedMemoryDataTransfer"
FUNCTION_DATA_CACHE = "FunctionDataCache"
HTTP_URI = "HttpUri"

REQUIRES_ROUTE_PARAMETERS = "RequiresRouteParameters"
# When this capability is enabled, logs are not piped back to the
# host from the worker. Logs will directly go to where the user has
# configured them to go. This is to ensure that the logs are not
Expand Down
9 changes: 7 additions & 2 deletions azure_functions_worker/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
PYTHON_THREADPOOL_THREAD_COUNT_DEFAULT,
PYTHON_THREADPOOL_THREAD_COUNT_MAX_37,
PYTHON_THREADPOOL_THREAD_COUNT_MIN,
REQUIRES_ROUTE_PARAMETERS
)
from .extension import ExtensionManager
from .http_v2 import (
Expand Down Expand Up @@ -405,6 +406,7 @@ async def _handle__worker_init_request(self, request):
if HttpV2Registry.http_v2_enabled():
capabilities[constants.HTTP_URI] = \
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
initialize_http_server(self._host)
capabilities[REQUIRES_ROUTE_PARAMETERS] = _TRUE

except HttpServerInitError:
raise
Expand Down Expand Up @@ -640,8 +642,10 @@ async def _handle__invocation_request(self, request):
http_request = await http_coordinator.get_http_request_async(
invocation_id)

await sync_http_request(http_request, invoc_request)
args[fi.trigger_metadata.get('param_name')] = http_request
trigger_arg_name = fi.trigger_metadata.get('param_name')
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
func_http_request = args[trigger_arg_name]
await sync_http_request(http_request, func_http_request)
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
args[trigger_arg_name] = http_request

fi_context = self._get_context(invoc_request, fi.name,
fi.directory)
Expand Down Expand Up @@ -792,6 +796,7 @@ async def _handle__function_environment_reload_request(self, request):
if HttpV2Registry.http_v2_enabled():
capabilities[constants.HTTP_URI] = \
initialize_http_server(self._host)
capabilities[REQUIRES_ROUTE_PARAMETERS] = _TRUE
except HttpServerInitError:
raise
except Exception as ex:
Expand Down
7 changes: 2 additions & 5 deletions azure_functions_worker/http_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,11 @@ async def catch_all(request: request_type): # type: ignore
from e


async def sync_http_request(http_request, invoc_request):
async def sync_http_request(http_request, func_http_request):
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
# Sync http request route params from invoc_request to http_request
route_params = {key: item.string for key, item
in invoc_request.trigger_metadata.items()
if key not in ['Headers', 'Query']}
(HttpV2Registry.ext_base().RequestTrackerMeta
.get_synchronizer()
.sync_route_params(http_request, route_params))
.sync_route_params(http_request, func_http_request.route_params))


class HttpV2Registry:
Expand Down
Loading