1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Copyright (c) 2026, Salesforce, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT
//! gRPC transport for Hyper database.
//!
//! This module provides gRPC-based connectivity to Hyper servers as an
//! alternative to the `PostgreSQL` wire protocol over TCP.
//!
//! gRPC transport is always available - no feature flags required.
//!
//! # Architecture
//!
//! The gRPC transport uses Protocol Buffers for message serialization and
//! returns query results in Apache Arrow IPC format. This provides:
//!
//! - Better support for load balancing
//! - Built-in streaming for large result sets
//! - HTTP/2 multiplexing
//! - Easier integration with service meshes
//!
//! # Limitations
//!
//! The gRPC interface is **read-only**:
//! - Only SELECT queries are supported
//! - No INSERT, UPDATE, DELETE, or DDL operations
//! - No COPY protocol for bulk data insertion
//!
//! For write operations, use the standard TCP connection.
//!
//! # Message Size Limits
//!
//! By default, the client uses a 64 MB message size limit ([`DEFAULT_MAX_MESSAGE_SIZE`]).
//! This is important when using [`TransferMode::Sync`], which returns all results in
//! a single gRPC response. For [`TransferMode::Adaptive`] (default) or [`TransferMode::Async`],
//! results are streamed in smaller chunks, making large message sizes less critical.
//!
//! ```
//! use hyperdb_api_core::client::grpc::{GrpcConfig, TransferMode};
//!
//! // For SYNC mode with large results, increase the limit
//! let config = GrpcConfig::new("http://localhost:7484")
//! .database("large_data.hyper")
//! .transfer_mode(TransferMode::Sync)
//! .max_message_size(256 * 1024 * 1024); // 256 MB
//! ```
//!
//! # Parameterized Queries
//!
//! gRPC supports parameterized queries using [`QueryParameters`] and [`ParameterStyle`]:
//!
//! ```no_run
//! use hyperdb_api_core::client::grpc::{GrpcClient, GrpcConfig, QueryParameters, ParameterStyle};
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! # let config = GrpcConfig::new("http://localhost:7484");
//! let mut client = GrpcClient::connect(config).await?;
//!
//! // Dollar-numbered parameters ($1, $2, ...) - use from_json_value for mixed types
//! let params = QueryParameters::from_json_value(&serde_json::json!([42, "Alice"]))?;
//! let result = client.execute_query_with_params(
//! "SELECT * FROM users WHERE id = $1 AND name = $2",
//! params,
//! ParameterStyle::DollarNumbered,
//! ).await?;
//!
//! // Named parameters (:id, :name, ...)
//! let params = QueryParameters::json_named()
//! .add("id", &42i64)?
//! .add("name", &"Alice")?
//! .build();
//! let result = client.execute_query_with_params(
//! "SELECT * FROM users WHERE id = :id AND name = :name",
//! params,
//! ParameterStyle::Named,
//! ).await?;
//! # Ok(())
//! # }
//! ```
//!
//! # Example
//!
//! ```no_run
//! use hyperdb_api_core::client::grpc::{GrpcClient, GrpcConfig};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let config = GrpcConfig::new("http://localhost:7484")
//! .database("my_database.hyper");
//!
//! let mut client = GrpcClient::connect(config).await?;
//!
//! // Execute a query and get Arrow IPC bytes
//! let arrow_data = client.execute_query_to_arrow("SELECT * FROM users").await?;
//!
//! // Or get parsed results
//! let result = client.execute_query("SELECT id, name FROM users").await?;
//! // Process Arrow data...
//!
//! Ok(())
//! }
//! ```
pub use ;
pub use ;
pub use GrpcError;
pub use GrpcChunkStream;
pub use ;
pub use ;
pub use ;
// Re-export transfer mode for users who want to specify it
pub use TransferMode;
// Re-export output format for advanced users
pub use OutputFormat;