Skip to content

Commit 0217fe4

Browse files
authored
Handle eventhub cardinality (#527)
1 parent 7896127 commit 0217fe4

File tree

14 files changed

+197
-4
lines changed

14 files changed

+197
-4
lines changed

.ci/linux_devops_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
set -e -x
44

5-
python -m pip install -U -e .[dev]
5+
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U -e .[dev]
66
python setup.py webhost

azure-pipelines-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
displayName: 'Install dotnet'
3737
- bash: |
3838
set -e -x
39-
python -m pip install -U -e .[dev]
39+
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U -e .[dev]
4040
python setup.py webhost
4141
displayName: 'Build'
4242
- bash: |

azure_functions_worker/bindings/datumdef.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ def from_typed_data(cls, td: protos.TypedData):
4949
val = td.bytes
5050
elif tt == 'json':
5151
val = td.json
52+
elif tt == 'collection_bytes':
53+
val = td.collection_bytes
54+
elif tt == 'collection_string':
55+
val = td.collection_string
56+
elif tt == 'collection_sint64':
57+
val = td.collection_sint64
5258
elif tt is None:
5359
return None
5460
else:

azure_functions_worker/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Capabilities
22
RAW_HTTP_BODY_BYTES = "RawHttpBodyBytes"
3+
TYPED_DATA_COLLECTION = "TypedDataCollection"

azure_functions_worker/dispatcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ async def _handle__worker_init_request(self, req):
216216

217217
capabilities = dict()
218218
capabilities[constants.RAW_HTTP_BODY_BYTES] = "true"
219+
capabilities[constants.TYPED_DATA_COLLECTION] = "true"
219220

220221
return protos.StreamingMessage(
221222
request_id=self.request_id,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def run(self):
249249
],
250250
extras_require={
251251
'dev': [
252-
'azure-functions==1.0.0b5',
252+
'azure-functions==1.0.3',
253253
'flake8~=3.5.0',
254254
'mypy',
255255
'pytest',
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import json
2+
3+
4+
def main(events):
5+
table_entries = []
6+
for event in events:
7+
json_entry = event.get_body()
8+
table_entry = json.loads(json_entry)
9+
table_entries.append(table_entry)
10+
11+
table_json = json.dumps(table_entries)
12+
13+
return table_json
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"scriptFile": "__init__.py",
3+
4+
"bindings": [
5+
{
6+
"type": "eventHubTrigger",
7+
"name": "events",
8+
"direction": "in",
9+
"cardinality": "many",
10+
"dataType": "string",
11+
"eventHubName": "python-worker-ci-eventhub-batch",
12+
"connection": "AzureWebJobsEventHubConnectionString"
13+
},
14+
{
15+
"direction": "out",
16+
"type": "table",
17+
"name": "$return",
18+
"tableName": "EventHubBatchTest",
19+
"connection": "AzureWebJobsStorage"
20+
}
21+
]
22+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import azure.functions as func
2+
3+
4+
def main(req: func.HttpRequest) -> str:
5+
events = req.get_body().decode('utf-8')
6+
return events
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"scriptFile": "__init__.py",
3+
4+
"bindings": [
5+
{
6+
"type": "httpTrigger",
7+
"direction": "in",
8+
"name": "req"
9+
},
10+
{
11+
"type": "eventHub",
12+
"name": "$return",
13+
"direction": "out",
14+
"eventHubName": "python-worker-ci-eventhub-batch",
15+
"connection": "AzureWebJobsEventHubConnectionString"
16+
}
17+
]
18+
}

0 commit comments

Comments
 (0)