Skip to main content
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

Source

pub fn new() -> Self

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
Source

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.
Source

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.

Source

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 to
  • body - Binary payload (Avro-encoded)
  • headers - The headers to send besides the content type; see RequestHeaders

Response body as bytes

Source

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 to
  • body - Binary payload (Avro-encoded)
  • headers - The headers to send besides the content type; see RequestHeaders
  • use_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
Source

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:

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.

Source

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.

Source

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.

Source

pub async fn get_text(&self, url: &str) -> Result<String, KineticaError>

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

Source

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.

Source

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source

fn default() -> Self

Returns the “default value” for a type. Read more