Databricks C++ SDK 0.2.4
Interact with Databricks via an SDK
Loading...
Searching...
No Matches
databricks::ConnectionPool Class Reference

Thread-safe connection pool for managing Databricks connections. More...

#include <connection_pool.h>

Classes

class  PooledConnection
 RAII wrapper for a pooled connection. More...
 
struct  Stats
 Get current pool statistics. More...
 

Public Member Functions

 ConnectionPool (const AuthConfig &auth, const SQLConfig &sql, size_t min_connections=1, size_t max_connections=10)
 Construct a ConnectionPool with modular configurations.
 
 ~ConnectionPool ()
 Destructor - closes all connections.
 
 ConnectionPool (const ConnectionPool &)=delete
 
ConnectionPooloperator= (const ConnectionPool &)=delete
 
 ConnectionPool (ConnectionPool &&)=delete
 
ConnectionPooloperator= (ConnectionPool &&)=delete
 
PooledConnection acquire ()
 Acquire a connection from the pool.
 
void warm_up ()
 Pre-warm the pool by creating minimum connections.
 
std::future< void > warm_up_async ()
 Asynchronously pre-warm the pool.
 
Stats get_stats () const
 Get current pool statistics.
 
void shutdown ()
 Shutdown the pool and close all connections.
 

Friends

class PooledConnection
 

Detailed Description

Thread-safe connection pool for managing Databricks connections.

ADVANCED API: Most users should enable pooling via PoolingConfig instead.

This class is for advanced users who need fine-grained control over connection pooling. For typical use cases, simply set pooling.enabled = true when building a Client, and pooling will be handled automatically.

The ConnectionPool manages a pool of reusable ODBC connections to improve performance by eliminating connection overhead for repeated operations.

Definition at line 30 of file connection_pool.h.

Constructor & Destructor Documentation

◆ ConnectionPool() [1/3]

databricks::ConnectionPool::ConnectionPool ( const AuthConfig auth,
const SQLConfig sql,
size_t  min_connections = 1,
size_t  max_connections = 10 
)

Construct a ConnectionPool with modular configurations.

Parameters
authAuthentication configuration
sqlSQL configuration
min_connectionsMinimum connections to maintain
max_connectionsMaximum connections allowed

◆ ~ConnectionPool()

databricks::ConnectionPool::~ConnectionPool ( )

Destructor - closes all connections.

◆ ConnectionPool() [2/3]

databricks::ConnectionPool::ConnectionPool ( const ConnectionPool )
delete

◆ ConnectionPool() [3/3]

databricks::ConnectionPool::ConnectionPool ( ConnectionPool &&  )
delete

Member Function Documentation

◆ acquire()

PooledConnection databricks::ConnectionPool::acquire ( )

Acquire a connection from the pool.

If no connections are available and the pool is not at max capacity, a new connection is created. Otherwise, waits for a connection to become available (up to connection_timeout_ms).

Returns
PooledConnection RAII wrapper
Exceptions
std::runtime_errorif timeout occurs or connection fails

◆ get_stats()

Stats databricks::ConnectionPool::get_stats ( ) const

Get current pool statistics.

Returns
Stats structure with current pool state

◆ operator=() [1/2]

ConnectionPool & databricks::ConnectionPool::operator= ( ConnectionPool &&  )
delete

◆ operator=() [2/2]

ConnectionPool & databricks::ConnectionPool::operator= ( const ConnectionPool )
delete

◆ shutdown()

void databricks::ConnectionPool::shutdown ( )

Shutdown the pool and close all connections.

◆ warm_up()

void databricks::ConnectionPool::warm_up ( )

Pre-warm the pool by creating minimum connections.

Creates min_connections in the pool without blocking. Useful for reducing initial latency.

◆ warm_up_async()

std::future< void > databricks::ConnectionPool::warm_up_async ( )

Asynchronously pre-warm the pool.

Creates min_connections in the background.

Returns
std::future<void> Future that completes when warm-up is done

Friends And Related Symbol Documentation

◆ PooledConnection

friend class PooledConnection
friend

Definition at line 179 of file connection_pool.h.


The documentation for this class was generated from the following file: