Skip to main content

Node

Struct Node 

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

A single TCP connection to a VoltDB server node.

Node represents a persistent, stateful TCP connection used to execute stored procedures and queries against a VoltDB cluster. Each Node maintains its own socket and spawns a dedicated background thread to asynchronously receive and dispatch responses from the server.

§Concurrency

Node is safe to use concurrently and supports multiple in-flight requests over the same connection. For automatic reconnection, load balancing, or managing multiple connections, use crate::Pool.

§Example

use voltdb_client_rust::{Node, NodeOpt, IpPort, block_for_result};

let opt = NodeOpt {
    ip_port: IpPort::new("localhost".to_string(), 21212),
    user: None,
    pass: None,
    connect_timeout: None,
    read_timeout: None,
};

let node = Node::new(opt)?;
let rx = node.query("SELECT * FROM my_table")?;
let table = block_for_result(&rx)?;

Implementations§

Source§

impl Node

Source

pub fn new(opt: NodeOpt) -> Result<Node, VoltError>

Creates a new connection to a VoltDB server node.

This method establishes a TCP connection to the specified host/port, performs authentication, and spawns a background listener thread for receiving asynchronous responses.

§Arguments
  • opt - Connection options including host, port, credentials, and timeouts.
§Timeouts
  • connect_timeout - If set, limits how long the connection attempt will wait. If not set, the connection attempt blocks indefinitely.
  • read_timeout - If set, socket read operations will timeout after this duration. This affects both the authentication phase and the background listener thread.
§Errors

Returns VoltError if:

  • The connection cannot be established (network error or timeout)
  • DNS resolution fails
  • Authentication fails
  • The server rejects the connection
§Example
use voltdb_client_rust::{Node, NodeOpt, IpPort};
use std::time::Duration;

let opt = NodeOpt {
    ip_port: IpPort::new("localhost".to_string(), 21212),
    user: None,
    pass: None,
    connect_timeout: Some(Duration::from_secs(5)),
    read_timeout: Some(Duration::from_secs(30)),
};
let node = Node::new(opt)?;
Source

pub fn get_sequence(&self) -> i64

Returns the next unique sequence number for request tracking.

Each request to VoltDB uses a unique handle (sequence number) for matching responses to requests.

Source

pub fn list_procedures(&self) -> Result<Receiver<VoltTable>, VoltError>

Lists all stored procedures available in the VoltDB database.

This calls the @SystemCatalog system procedure with “PROCEDURES” argument.

§Returns

A receiver that will yield a VoltTable containing procedure metadata.

Source

pub fn call_sp( &self, query: &str, param: Vec<&dyn Value>, ) -> Result<Receiver<VoltTable>, VoltError>

Executes a stored procedure with the given parameters.

§Arguments
  • query - The name of the stored procedure (e.g., “@AdHoc”, “MyProcedure”)
  • param - Vector of parameter values. Use volt_param! macro for convenience.
§Returns

A receiver that will yield the result VoltTable when available.

§Example
use voltdb_client_rust::{Node, NodeOpt, IpPort, Value, block_for_result, volt_param};

let node = Node::new(opt)?;
let id = 1i32;
let name = "test".to_string();
let rx = node.call_sp("MyProcedure", volt_param![id, name])?;
let result = block_for_result(&rx)?;
Source

pub fn upload_jar(&self, bs: Vec<u8>) -> Result<Receiver<VoltTable>, VoltError>

Uploads a JAR file containing stored procedure classes to VoltDB.

This calls the @UpdateClasses system procedure to deploy new classes.

§Arguments
  • bs - The JAR file contents as bytes
Source

pub fn query(&self, sql: &str) -> Result<Receiver<VoltTable>, VoltError>

Executes an ad-hoc SQL query.

This is a convenience method that calls the @AdHoc system procedure.

§Arguments
  • sql - The SQL query string to execute
§Returns

A receiver that will yield the result VoltTable when available.

§Example
use voltdb_client_rust::{Node, NodeOpt, IpPort, block_for_result};

let node = Node::new(opt)?;
let rx = node.query("SELECT COUNT(*) FROM users")?;
let result = block_for_result(&rx)?;
Source

pub fn ping(&self) -> Result<(), VoltError>

Sends a ping to the VoltDB server.

This can be used to keep the connection alive or verify connectivity. The ping response is handled internally and not returned to the caller.

Source

pub fn shutdown(&mut self) -> Result<(), VoltError>

Gracefully shuts down the connection.

This stops the background listener thread and closes the TCP connection. The Node will be unusable after calling this method.

Note: This is automatically called when the Node is dropped.

Trait Implementations§

Source§

impl Debug for Node

Source§

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

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

impl Drop for Node

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Connection for Node

Auto Trait Implementations§

§

impl !Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnwindSafe for Node

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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