Skip to main content

Module node

Module node 

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

§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§

ConnInfo
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 Node connection.
Opts
Connection options for VoltDB client.
OptsBuilder
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