-
Notifications
You must be signed in to change notification settings - Fork 181
Closed
Description
I'm using a Julia webserver to provide some data to a Grafana dashboard. Opening a dashboard immediately sends multiple requests to the server, some of which take >1s to complete, therefore I was trying to make the request handling work in multiple threads, as currently one can see the panels being filled with a delay one after the other. I couldnt figure it out though, it seems that HTTP.jl requires the response of one request being sent before accepting a new request. My guess is it can't be done currently and would require new functionality, if Im wrong please correct me. Therefore I would like to propose to add this functionality in some way for some future version of HTTP.
I could imagine something like this
# julia -t 8
using HTTP
const requestChannel = Channel{HTTP.Request}(8)
# "autorespond" option doesnt exist yet
HTTP.serve(; autorespond = false) do request
put!(requestChannel, request)
return nothing
end
function handleRequests()
while true
request = take!(requestChannel)
sleep(5) # work being done
response = HTTP.Response(200)
HTTP.respond(request, response) # this function doesnt exist
end
end
for i = 1:8
Threads.@spawn handleRequests()
endMetadata
Metadata
Assignees
Labels
No labels