class Async::HTTP::Mock::Endpoint
This is an endpoint which bridges a client with a local server.
def connect
def connect local, remote = ::Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM) @queue.enqueue(remote) return local end
def initialize(protocol = Protocol::HTTP2, scheme = "http", authority = "localhost", queue: Queue.new)
def initialize(protocol = Protocol::HTTP2, scheme = "http", authority = "localhost", queue: Queue.new) @protocol = protocol @scheme = scheme @authority = authority @queue = queue end
def run(parent: Task.current, &block)
- Yield: - the requests as they come in.
def run(parent: Task.current, &block) while peer = @queue.dequeue server = @protocol.server(peer) parent.async do server.each(&block) end end end
def wrap(endpoint)
def wrap(endpoint) self.class.new(@protocol, endpoint.scheme, endpoint.authority, queue: @queue) end