mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-19 13:03:44 +00:00
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:
@ -3,7 +3,6 @@
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
# import logging
|
||||
import azure.functions as func
|
||||
from onefuzztypes.enums import ErrorCode, JobState
|
||||
from onefuzztypes.models import Error, TaskConfig
|
||||
@ -11,6 +10,7 @@ from onefuzztypes.requests import TaskGet, TaskSearch
|
||||
from onefuzztypes.responses import BoolResult
|
||||
|
||||
from ..onefuzzlib.endpoint_authorization import call_if_user
|
||||
from ..onefuzzlib.events import get_events
|
||||
from ..onefuzzlib.jobs import Job
|
||||
from ..onefuzzlib.pools import NodeTasks
|
||||
from ..onefuzzlib.request import not_ok, ok, parse_request
|
||||
@ -99,7 +99,13 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
|
||||
return ok(task)
|
||||
|
||||
|
||||
def main(req: func.HttpRequest) -> func.HttpResponse:
|
||||
def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
|
||||
methods = {"GET": get, "POST": post, "DELETE": delete}
|
||||
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
|
||||
|
@ -17,6 +17,12 @@
|
||||
"type": "http",
|
||||
"direction": "out",
|
||||
"name": "$return"
|
||||
},
|
||||
{
|
||||
"type": "signalR",
|
||||
"direction": "out",
|
||||
"name": "dashboard",
|
||||
"hubName": "dashboard"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user