always set SignalR events at the end of handlers (#445)

Addresses an issue where events meant for SignalR do not get sent to the service when an App Service instance spins down before a timer event fires.
This commit is contained in:
bmc-msft
2021-01-21 05:31:02 -05:00
committed by GitHub
parent f3d81566e3
commit b499b9b17d
55 changed files with 708 additions and 414 deletions

View File

@ -10,6 +10,7 @@ from onefuzztypes.requests import NodeGet, NodeSearch, NodeUpdate
from onefuzztypes.responses import BoolResult
from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.pools import Node, NodeTasks
from ..onefuzzlib.request import not_ok, ok, parse_request
@ -100,7 +101,13 @@ def patch(req: func.HttpRequest) -> func.HttpResponse:
return ok(BoolResult(result=True))
def main(req: func.HttpRequest) -> func.HttpResponse:
def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "PATCH": patch, "DELETE": delete, "POST": post}
method = methods[req.method]
return call_if_user(req, method)
result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -1,22 +1,28 @@
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"patch",
"delete",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"patch",
"delete",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
}