This commit is contained in:
Родитель
4d0feb7993
Коммит
26395f6b20
|
@ -181,10 +181,10 @@ async def from_incoming_proto(
|
|||
# if the binding is an sdk type binding
|
||||
if is_deferred_binding:
|
||||
return await deferred_bindings_decode(binding=binding,
|
||||
pb=pb,
|
||||
pytype=pytype,
|
||||
datum=datum,
|
||||
metadata=metadata)
|
||||
pb=pb,
|
||||
pytype=pytype,
|
||||
datum=datum,
|
||||
metadata=metadata)
|
||||
return binding.decode(datum, trigger_metadata=metadata)
|
||||
except NotImplementedError:
|
||||
# Binding does not support the data.
|
||||
|
@ -278,10 +278,10 @@ def to_outgoing_param_binding(binding: str, obj: typing.Any, *,
|
|||
|
||||
|
||||
async def deferred_bindings_decode(binding: typing.Any,
|
||||
pb: protos.ParameterBinding, *,
|
||||
pytype: typing.Optional[type],
|
||||
datum: typing.Any,
|
||||
metadata: typing.Any):
|
||||
pb: protos.ParameterBinding, *,
|
||||
pytype: typing.Optional[type],
|
||||
datum: typing.Any,
|
||||
metadata: typing.Any):
|
||||
"""
|
||||
This cache holds deferred binding types (ie. BlobClient, ContainerClient)
|
||||
That have already been created, so that the worker can reuse the
|
||||
|
@ -299,8 +299,8 @@ async def deferred_bindings_decode(binding: typing.Any,
|
|||
datum.value.content))
|
||||
else:
|
||||
deferred_binding_type = await binding.decode(datum,
|
||||
trigger_metadata=metadata,
|
||||
pytype=pytype)
|
||||
trigger_metadata=metadata,
|
||||
pytype=pytype)
|
||||
deferred_bindings_cache[(pb.name,
|
||||
pytype,
|
||||
datum.value.content)] = deferred_binding_type
|
||||
|
|
|
@ -296,7 +296,7 @@ async def aio_ssd(req: func.HttpRequest,
|
|||
decoded = file.decode('utf-8')
|
||||
return str(decoded)
|
||||
|
||||
|
||||
|
||||
@app.function_name(name="invalid_connection_info")
|
||||
@app.blob_input(arg_name="client",
|
||||
path="python-worker-tests/test-blobclient-triggered.txt",
|
||||
|
|
|
@ -183,12 +183,16 @@ class TestDeferredBindingsBlobFunctions(testutils.WebHostTestCase):
|
|||
def test_aio_clients(self):
|
||||
r = self.webhost.request('GET', 'aio_blob_client')
|
||||
self.assertEqual(r.status_code, 200)
|
||||
self.assertEqual(r.text, ('b\'{"name": "test-blobclient-trigger.txt", "length": 9, "content": '
|
||||
'"DummyData"}\''))
|
||||
self.assertEqual(r.text,
|
||||
('b\'{"name": "test-blobclient-trigger.txt",'
|
||||
' "length": 9, "content": '
|
||||
'"DummyData"}\''))
|
||||
|
||||
r = self.webhost.request('GET', 'aio_container_client')
|
||||
self.assertEqual(r.status_code, 200)
|
||||
self.assertEqual(r.text, '{\r\n "name": "python-worker-tests",\r\n "content": "DummyData"\r\n}')
|
||||
self.assertEqual(r.text,
|
||||
'{\r\n "name": "python-worker-tests",\r\n '
|
||||
'"content": "DummyData"\r\n}')
|
||||
|
||||
r = self.webhost.request('GET', 'aio_ssd')
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
|
Загрузка…
Ссылка в новой задаче