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 MBImplementations§
Source§impl GrpcConfig
impl GrpcConfig
Sourcepub fn new(endpoint: impl Into<String>) -> Self
pub fn new(endpoint: impl Into<String>) -> Self
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");Sourcepub fn database(self, database: impl Into<String>) -> Self
pub fn database(self, database: impl Into<String>) -> Self
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");Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Sets the connection timeout.
This is the maximum time to wait for the initial connection to be established. Default is 30 seconds.
Sourcepub fn request_timeout(self, timeout: Duration) -> Self
pub fn request_timeout(self, timeout: Duration) -> Self
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).
Sourcepub fn transfer_mode(self, mode: TransferMode) -> Self
pub fn transfer_mode(self, mode: TransferMode) -> Self
Sets the transfer mode for query results.
TransferMode::Sync- All results inExecuteQueryresponse (simple, 100s timeout)TransferMode::Async- Header only, fetch results viaGetQueryResultTransferMode::Adaptive- First chunk inline, rest viaGetQueryResult(default)
Adaptive is recommended for most workloads as it provides the best balance
of latency and reliability.
Sourcepub fn max_message_size(self, size: usize) -> Self
pub fn max_message_size(self, size: usize) -> Self
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);Sourcepub fn max_decoding_message_size(self, size: usize) -> Self
pub fn max_decoding_message_size(self, size: usize) -> Self
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 MBSourcepub fn max_encoding_message_size(self, size: usize) -> Self
pub fn max_encoding_message_size(self, size: usize) -> Self
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.
Sourcepub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
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");Sourcepub fn headers(
self,
headers: impl IntoIterator<Item = (String, String)>,
) -> Self
pub fn headers( self, headers: impl IntoIterator<Item = (String, String)>, ) -> Self
Adds multiple headers at once.
Sourcepub fn setting(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn setting(self, key: impl Into<String>, value: impl Into<String>) -> Self
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");Sourcepub fn database_path(&self) -> Option<&str>
pub fn database_path(&self) -> Option<&str>
Returns the database path, if set.
Sourcepub fn get_max_decoding_message_size(&self) -> usize
pub fn get_max_decoding_message_size(&self) -> usize
Returns the maximum decoding message size.
Sourcepub fn get_max_encoding_message_size(&self) -> usize
pub fn get_max_encoding_message_size(&self) -> usize
Returns the maximum encoding message size.
Sourcepub fn with_bearer_auth(
self,
bearer_token: impl Into<String>,
audience: impl Into<String>,
) -> Self
pub fn with_bearer_auth( self, bearer_token: impl Into<String>, audience: impl Into<String>, ) -> Self
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
impl Clone for GrpcConfig
Source§fn clone(&self) -> GrpcConfig
fn clone(&self) -> GrpcConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GrpcConfig
impl Debug for GrpcConfig
Auto Trait Implementations§
impl Freeze for GrpcConfig
impl RefUnwindSafe for GrpcConfig
impl Send for GrpcConfig
impl Sync for GrpcConfig
impl Unpin for GrpcConfig
impl UnsafeUnpin for GrpcConfig
impl UnwindSafe for GrpcConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request