Skip to content

Commit a798640

Browse files
committed
get_raw_bindings method
1 parent 53bcc2e commit a798640

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

azure_functions_worker/bindings/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from .meta import has_implicit_output
99
from .meta import is_trigger_binding, load_binding_registry
1010
from .meta import from_incoming_proto, to_outgoing_proto, \
11-
to_outgoing_param_binding, check_deferred_bindings_enabled
11+
to_outgoing_param_binding, check_deferred_bindings_enabled, \
12+
get_deferred_raw_bindings
1213
from .out import Out
1314

1415

@@ -19,5 +20,6 @@
1920
'check_input_type_annotation', 'check_output_type_annotation',
2021
'has_implicit_output',
2122
'from_incoming_proto', 'to_outgoing_proto', 'TraceContext', 'RetryContext',
22-
'to_outgoing_param_binding', 'check_deferred_bindings_enabled'
23+
'to_outgoing_param_binding', 'check_deferred_bindings_enabled',
24+
'get_deferred_raw_bindings'
2325
)

azure_functions_worker/bindings/meta.py

+12
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,15 @@ def check_deferred_bindings_enabled(param_anno: type,
284284
return True, True
285285
else:
286286
return deferred_bindings_enabled, False
287+
288+
289+
def get_deferred_raw_bindings(indexed_function, input_types):
290+
"""
291+
Calls a method from the base extension that generates the raw bindings
292+
for a given function. It also returns logs for that function including
293+
the defined binding type and if deferred bindings is enabled for that
294+
binding.
295+
"""
296+
raw_bindings, bindings_logs = DEFERRED_BINDING_REGISTRY.get_raw_bindings(
297+
indexed_function, input_types)
298+
return raw_bindings, bindings_logs

azure_functions_worker/loader.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ def build_variable_interval_retry(retry, max_retry_count, retry_strategy):
122122

123123
def process_indexed_function(functions_registry: functions.Registry,
124124
indexed_functions):
125+
"""
126+
fx_metadata_results is a list of the RpcFunctionMetadata for
127+
all the functions in the particular app.
128+
129+
fx_binding_logs represents a dictionary of each function in
130+
the app and its corresponding bindings. The raw bindings and
131+
binding logs are generated from the base extension if the
132+
function is using deferred bindings. If not, the raw bindings
133+
come from the azure-functions sdk and no additional binding
134+
logs are generated.
135+
"""
125136
fx_metadata_results = []
126137
fx_bindings_logs = {}
127138
for indexed_function in indexed_functions:
@@ -251,11 +262,19 @@ def get_fx_raw_bindings(indexed_function, function_info):
251262
"""
252263
If deferred bindings is enabled at the function level,
253264
raw bindings are generated through the base extension.
265+
This method returns two things: the raw bindings for that
266+
function and a dict the corresponding logs.
267+
268+
254269
If not, raw bindings are generated through azure-functions.
270+
An empty dict is returned as we are not logging any
271+
additional information if deferred bindings is not enabled
272+
for this function.
255273
"""
256274
if function_info.deferred_bindings_enabled:
257-
return bindings.meta.DEFERRED_BINDING_REGISTRY.get_raw_bindings(
275+
raw_bindings, bindings_logs = bindings.get_deferred_raw_bindings(
258276
indexed_function, function_info.input_types)
277+
return raw_bindings, bindings_logs
259278

260279
else:
261280
return indexed_function.get_raw_bindings(), {}

0 commit comments

Comments
 (0)