Cryload::PhasedClient - cryload 6.0.0

# class Cryload::PhasedClient

- Cryload::PhasedClient
- HTTP::Client
- Reference
- Object

##
Overview

`HTTP::Client` that splits connection setup into DNS, TCP connect and TLS handshake timings.

`HTTP::Client` resolves and connects lazily inside its private `#io`, so overriding that is the only place the three phases can be measured separately without giving up automatic reconnection when a keep-alive connection is dropped. Handing a pre-connected socket to `HTTP::Client.new(io, ...)` would measure the phases just as well but marks the client non-reconnectable, which turns every server-side keep-alive timeout into a hard failure.

##
Defined in:

cryload/phased_client.cr

##
Constructors

- .new(io : IO, host : String, port : Int32, dns_ms : Float64, connect_ms : Float64, tls_ms : Float64 | Nil)

  Adopts an already-established connection (the HTTPS-over-proxy CONNECT tunnel) together with the phase timings measured while building it.

- .new(host : String, port = nil, tls : HTTP::Client::TLSContext = nil)

##
Instance Method Summary

- #connections_opened : Int64
- #last_connect_ms : Float64
- #last_dns_ms : Float64
- #last_tls_ms : Float64 | Nil

  Nil when the last connection carried no TLS handshake, so a plain HTTP run reports zero handshakes instead of a run of zero-millisecond ones.

##
Constructor Detail

def self.new(io : IO, host : String, port : Int32, dns_ms : Float64, connect_ms : Float64, tls_ms : Float64 | Nil) #

Adopts an already-established connection (the HTTPS-over-proxy CONNECT tunnel) together with the phase timings measured while building it.

def self.new(host : String, port = nil, tls : HTTP::Client::TLSContext = nil) #

##
Instance Method Detail

def connections_opened : Int64 #
def last_connect_ms : Float64 #
def last_dns_ms : Float64 #
def last_tls_ms : Float64 | Nil #

Nil when the last connection carried no TLS handshake, so a plain HTTP run reports zero handshakes instead of a run of zero-millisecond ones.