Method: Async::HTTP::Client#initialize

Defined in:
lib/async/http/client.rb

#initialize(endpoint, protocol: endpoint.protocol, scheme: endpoint.scheme, authority: endpoint.authority, retries: DEFAULT_RETRIES, connection_limit: DEFAULT_CONNECTION_LIMIT) ⇒ Client

Provides a robust interface to a server.

  • If there are no connections, it will create one.

  • If there are already connections, it will reuse it.

  • If a request fails, it will retry it up to N times if it was idempotent.

The client object will never become unusable. It internally manages persistent connections (or non-persistent connections if that’s required).

Parameters:

  • endpoint (Endpoint)

    the endpoint to connnect to.

  • protocol (Protocol::HTTP1 | Protocol::HTTP2 | Protocol::HTTPS) (defaults to: endpoint.protocol)

    the protocol to use.

  • scheme (String) (defaults to: endpoint.scheme)

    The default scheme to set to requests.

  • authority (String) (defaults to: endpoint.authority)

    The default authority to set to requests.



50
51
52
53
54
55
56
57
58
59
# File 'lib/async/http/client.rb', line 50

def initialize(endpoint, protocol: endpoint.protocol, scheme: endpoint.scheme, authority: endpoint.authority, retries: DEFAULT_RETRIES, connection_limit: DEFAULT_CONNECTION_LIMIT)
	@endpoint = endpoint
	@protocol = protocol
	
	@retries = retries
	@pool = make_pool(connection_limit)
	
	@scheme = scheme
	@authority = authority
end