Expand description
§VoltDB Node Connection
This module provides the core TCP connection handling for communicating with VoltDB servers.
§Architecture
The connection uses a single-threaded TCP listener design:
- We spawn one dedicated thread to synchronously read from the TcpStream.
- Each incoming message is dispatched via channels to the rest of the application, allowing users to perform asynchronous operations on the received data.
- Using
Mutex<TcpStream>for single Stream would introduce blocking and contention, because locking for each read/write would stall other operations. This design avoids that while keeping the network I/O simple and efficient.
§Timeouts
The module supports two types of timeouts:
- Connection timeout: Limits how long the initial TCP connection attempt will wait.
Use
OptsBuilder::connect_timeoutor setNodeOpt::connect_timeout. - Read timeout: Limits how long socket read operations will wait for data.
This affects both the authentication handshake and the background listener thread.
Use
OptsBuilder::read_timeoutor setNodeOpt::read_timeout.
§Example
use voltdb_client_rust::{Opts, Pool};
use std::time::Duration;
// Create connection options with timeouts
let opts = Opts::builder()
.host("localhost", 21212)
.connect_timeout(Duration::from_secs(5))
.read_timeout(Duration::from_secs(30))
.build()
.unwrap();
// Create a connection pool
let mut pool = Pool::new(opts)?;
let mut conn = pool.get_conn()?;
// Execute a query
let result = conn.query("SELECT * FROM my_table")?;Structs§
- Conn
Info - Connection metadata returned by the VoltDB server during authentication.
- IpPort
- Host and port pair for VoltDB server connections.
- Node
- A single TCP connection to a VoltDB server node.
- NodeOpt
- Options for creating a single
Nodeconnection. - Opts
- Connection options for VoltDB client.
- Opts
Builder - Builder for connection options.
Traits§
- Connection
- Marker trait for VoltDB connections.
Functions§
- block_
for_ result - Blocks until a response is received and converts any VoltDB errors.
- get_
node - Creates a new connection to a VoltDB server using an address string.
- reset