Execution contexts and `HTTP::Server`

What is the plan for things like HTTP::Server regarding execution contexts? Is the idea that the HTTP::Server will receive an execution context to spawn the new fibers into?

context = Fiber::ExecutionContext::Parallel.new("http.server", 8)
log = Log.for("http.server")
handlers = [
  HTTP::LogHandler.new(log),
  HTTP::CompressHandler.new,
] of HTTP::Handler
http = HTTP::Server.new(handlers, context)

I have a proof of concept implementation of this:

class HTTP::Server::WithExecutionContext < HTTP::Server
  private getter execution_context : Fiber::ExecutionContext

  def initialize(handlers : Indexable(HTTP::Handler), @execution_context)
    super HTTP::Server.build_middleware(handlers)
  end

  def dispatch(io)
    execution_context.spawn { handle_client io }
  end
end
1 Like