Skip to main content

GrpcConfig

Struct GrpcConfig 

Source
pub struct GrpcConfig { /* private fields */ }
Expand description

Configuration for gRPC connections to Hyper servers.

§Example

use hyperdb_api_core::client::grpc::GrpcConfig;
use std::time::Duration;

let config = GrpcConfig::new("http://localhost:7484")
    .database("my_database.hyper")
    .connect_timeout(Duration::from_secs(30))
    .request_timeout(Duration::from_secs(60));

§Message Size Limits

By default, the client uses a 64 MB message size limit. This is important when using TransferMode::Sync, which returns all results in a single response. For TransferMode::Adaptive (the default) or TransferMode::Async, results are streamed in chunks, making large message sizes less critical.

use hyperdb_api_core::client::grpc::{GrpcConfig, TransferMode};

// For very large SYNC results, increase the limit:
let config = GrpcConfig::new("http://localhost:7484")
    .transfer_mode(TransferMode::Sync)
    .max_message_size(256 * 1024 * 1024); // 256 MB

Implementations§

Source§

impl GrpcConfig

Source

pub fn new(endpoint: impl Into<String>) -> GrpcConfig

Creates a new gRPC configuration with the given endpoint.

The endpoint should be a URL like http://localhost:7484 or https://hyper-service.example.com:443.

§Example
use hyperdb_api_core::client::grpc::GrpcConfig;

let config = GrpcConfig::new("http://localhost:7484");
Source

pub fn database(self, database: impl Into<String>) -> GrpcConfig

Sets the database path to attach.

For a single database, provide the path directly. For multiple databases, provide a JSON array like [{"path": "db1.hyper", "alias": "db1"}, ...].

§Example
use hyperdb_api_core::client::grpc::GrpcConfig;

let config = GrpcConfig::new("http://localhost:7484")
    .database("my_database.hyper");
Source

pub fn connect_timeout(self, timeout: Duration) -> GrpcConfig

Sets the connection timeout.

This is the maximum time to wait for the initial connection to be established. Default is 30 seconds.

Source

pub fn request_timeout(self, timeout: Duration) -> GrpcConfig

Sets the request timeout.

This is the maximum time to wait for a single request to complete. Default is 100 seconds (matching Hyper’s server-side timeout for SYNC mode).

Source

pub fn transfer_mode(self, mode: TransferMode) -> GrpcConfig

Sets the transfer mode for query results.

  • TransferMode::Sync - All results in ExecuteQuery response (simple, 100s timeout)
  • TransferMode::Async - Header only, fetch results via GetQueryResult
  • TransferMode::Adaptive - First chunk inline, rest via GetQueryResult (default)

Adaptive is recommended for most workloads as it provides the best balance of latency and reliability.

Source

pub fn max_message_size(self, size: usize) -> GrpcConfig

Sets the maximum message size for both encoding (sending) and decoding (receiving).

This is a convenience method that sets both max_decoding_message_size and max_encoding_message_size to the same value.

Default is 64 MB. You may need to increase this when using TransferMode::Sync with queries that return large result sets.

§Example
use hyperdb_api_core::client::grpc::{GrpcConfig, TransferMode};

// Allow up to 256 MB messages for large SYNC queries
let config = GrpcConfig::new("http://localhost:7484")
    .transfer_mode(TransferMode::Sync)
    .max_message_size(256 * 1024 * 1024);
Source

pub fn max_decoding_message_size(self, size: usize) -> GrpcConfig

Sets the maximum size for decoding (receiving) gRPC messages.

Default is 64 MB. This is particularly important when using TransferMode::Sync, which returns all query results in a single response message. If your queries return more data than this limit, you will receive a “message too large” error.

For TransferMode::Adaptive (default) or TransferMode::Async, results are streamed in smaller chunks, making this limit less critical.

§Example
use hyperdb_api_core::client::grpc::GrpcConfig;

let config = GrpcConfig::new("http://localhost:7484")
    .max_decoding_message_size(128 * 1024 * 1024); // 128 MB
Source

pub fn max_encoding_message_size(self, size: usize) -> GrpcConfig

Sets the maximum size for encoding (sending) gRPC messages.

Default is 64 MB. This affects the size of requests sent to the server, which is typically small for queries but may be larger for parameterized queries with large parameter payloads.

Source

pub fn header( self, key: impl Into<String>, value: impl Into<String>, ) -> GrpcConfig

Adds a header to send with all requests.

This is useful for authentication tokens, routing hints, or other metadata.

§Example
use hyperdb_api_core::client::grpc::GrpcConfig;

let config = GrpcConfig::new("https://hyper.example.com")
    .header("authorization", "Bearer my-token")
    .header("x-tenant-id", "tenant-123");
Source

pub fn headers( self, headers: impl IntoIterator<Item = (String, String)>, ) -> GrpcConfig

Adds multiple headers at once.

Source

pub fn setting( self, key: impl Into<String>, value: impl Into<String>, ) -> GrpcConfig

Adds a connection setting.

These settings are passed to Hyper as query parameters. See Hyper documentation for available settings.

§Example
use hyperdb_api_core::client::grpc::GrpcConfig;

let config = GrpcConfig::new("http://localhost:7484")
    .setting("log_level", "debug");
Source

pub fn endpoint(&self) -> &str

Returns the endpoint URL.

Source

pub fn database_path(&self) -> Option<&str>

Returns the database path, if set.

Source

pub fn is_tls(&self) -> bool

Returns whether TLS is enabled.

Source

pub fn get_max_decoding_message_size(&self) -> usize

Returns the maximum decoding message size.

Source

pub fn get_max_encoding_message_size(&self) -> usize

Returns the maximum encoding message size.

Source

pub fn with_bearer_auth( self, bearer_token: impl Into<String>, audience: impl Into<String>, ) -> GrpcConfig

Configures authentication headers with bearer token and audience.

This is a lower-level method for manually setting authentication headers.

§Arguments
  • bearer_token - The full Authorization header value (e.g., “Bearer abc123…”)
  • audience - The tenant URL or audience value

Trait Implementations§

Source§

impl Clone for GrpcConfig

Source§

fn clone(&self) -> GrpcConfig

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§

impl Debug for GrpcConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for GrpcConfig

Source§

fn default() -> GrpcConfig

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,