class Generic < ::Protocol::HTTP::Middleware
- Inherits from
::Protocol::HTTP::Middleware
The common middleware implementation for isolated execution contexts.
Definitions
def call(request)
Execute a request using a new isolated execution context.
Signature
-
parameter
requestProtocol::HTTP::Request The request to execute.
-
returns
Protocol::HTTP::Response The remote response.
Implementation
def call(request)
parent = ::Async::Task.current
endpoint, worker_streams = Transport.pair
backend = spawn(worker_streams)
Execution.new(endpoint, backend, request, parent).call
rescue
endpoint&.close
raise
end
def spawn(worker_streams)
Spawn the isolated execution context.
Signature
-
parameter
worker_streamsArray(IO) The worker transport streams.
-
returns
Thread | Ractor The isolated execution context.
Implementation
def spawn(worker_streams)
raise NotImplementedError
end