pub struct HyperClient /* private fields */ High-performance HTTP client using hyper with connection pooling.
This client is optimized for:
- HTTP/2 multiplexing
- Aggressive connection reuse
- Minimal abstraction overhead
Implementations
impl HyperClient
Creates a new HyperClient with the default HttpClientConfig.
Since the server doesn’t support HTTP/2, we optimize for HTTP/1.1:
- Pooled connections, with a long idle timeout to maximize reuse
- TCP_NODELAY for low latency
- Fast connection establishment
pub fn with_tls_options(bypass_ssl_cert_check: bool) -> Self
Creates a new HyperClient with the default HttpClientConfig, optionally accepting any server certificate.
bypass_ssl_cert_check- Accept any server certificate. See [AcceptAnyServerCert] for what this gives up.
pub fn with_config(config: &HttpClientConfig) -> Self
Creates a new HyperClient with the given settings.
The connector speaks both http and https, chosen per request from the URL scheme, so a plaintext deployment is unaffected by TLS being available.
pub async fn post_binary( &self, url: &str, body: Vec<u8>, headers: &RequestHeaders, ) -> Result<Bytes, KineticaError>
Sends a POST request with binary body.
This is optimized for Avro binary payloads sent to Kinetica.
url- Full URL to send request tobody- Binary payload (Avro-encoded)headers- The headers to send besides the content type; seeRequestHeaders
Response body as bytes
pub async fn post_binary_with_compression( &self, url: &str, body: Vec<u8>, headers: &RequestHeaders, use_snappy: bool, ) -> Result<Bytes, KineticaError>
Sends a POST request with binary body, optionally compressed with Snappy.
This is optimized for Avro binary payloads sent to Kinetica.
url- Full URL to send request tobody- Binary payload (Avro-encoded)headers- The headers to send besides the content type; seeRequestHeadersuse_snappy- Whether to compress the body with Snappy
Response body as bytes
When use_snappy is true:
- The body is compressed using Snappy compression
- Content-Type is set to
application/x-snappy - This can significantly reduce transfer time for large payloads
pub async fn post_binary_raw( &self, url: &str, body: Vec<u8>, headers: &RequestHeaders, use_snappy: bool, ) -> Result<RawResponse, KineticaError>
Sends a POST request like Self::post_binary_with_compression, but returns the response whatever its status, for the caller to interpret.
Failures are classified as follows:
- Failing to send the request or to receive a response, including a timeout, is a
KineticaError::Connection, which fails over. - A TLS failure is a
KineticaError::Config, which does not: another cluster would present the same certificate problem. - Failing to read the body, including a timeout, is a
KineticaError::Http.
Before any of that, a failed send or a 502 or 503 is retried up to HttpClientConfig::max_retries times; the last outcome is what is classified.
pub async fn post_json_raw( &self, url: &str, json: Option<String>, headers: &RequestHeaders, ) -> Result<RawResponse, KineticaError>
Sends a POST with a JSON body, or with none, and returns the response whatever its status; failures are classified as Self::post_binary_raw classifies them.
pub async fn post_binary_raw_fast( &self, url: &str, body: Vec<u8>, headers: &RequestHeaders, ) -> Result<RawResponse, KineticaError>
Sends a POST request like Self::post_binary_raw, through the fast client, for a quick status check: its own connection pool and limits, a connect timeout and a response timeout of [FAST_CONNECTION_TIMEOUT] each, and no retries.
The two timeouts cannot be told apart here, so the wait for a response is bounded by both together.
Sends a GET request and returns the response body as text.
This is used for simple health checks like pinging the server.
url- Full URL to send request to
Response body as a string
pub async fn get_text_with_timeout( &self, url: &str, limit: Duration, ) -> Result<String, KineticaError>
Like Self::get_text, for health checks that must answer quickly: limit replaces the client’s timeouts, and the request goes through the separate health-check connection limits.
pub async fn ping( &self, url: &str, headers: &RequestHeaders, limit: Option<Duration>, ) -> Result<String, KineticaError>
Sends a GET with headers and returns the body as text, whatever the status; limit bounds the response and the body each, None waiting as long as it takes.
Trait Implementations
impl Clone for HyperClient
fn clone(&self) -> HyperClient
fn clone_from(&mut self, source: &Self)
source. Read more