Skip to content

Commit

Permalink
Expose healthcheck interval setting on async connection pool
Browse files Browse the repository at this point in the history
  • Loading branch information
criminosis committed Aug 27, 2024
1 parent cdcc212 commit 2b72a1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions gremlin-client/src/aio/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl GremlinClient {
let pool = Pool::builder()
.get_timeout(opts.pool_get_connection_timeout)
.max_open(pool_size as u64)
.health_check_interval(opts.pool_healthcheck_interval)
.build(manager);

Ok(GremlinClient {
Expand Down
9 changes: 9 additions & 0 deletions gremlin-client/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ impl ConnectionOptionsBuilder {
self
}

/// Only applicable to async client. By default a connection is checked on each return to the pool (None)
/// This allows setting an interval of how often it is checked on return.
pub fn pool_healthcheck_interval(mut self, pool_healthcheck_interval: Option<Duration>) -> Self {
self.0.pool_healthcheck_interval = pool_healthcheck_interval;
self
}

/// Both the sync and async pool providers use a default of 30 seconds,
/// Async pool interprets `None` as no timeout. Sync pool maps `None` to the default value
pub fn pool_connection_timeout(mut self, pool_connection_timeout: Option<Duration>) -> Self {
Expand Down Expand Up @@ -171,6 +178,7 @@ pub struct ConnectionOptions {
pub(crate) host: String,
pub(crate) port: u16,
pub(crate) pool_size: u32,
pub(crate) pool_healthcheck_interval: Option<Duration>,
pub(crate) pool_get_connection_timeout: Option<Duration>,
pub(crate) credentials: Option<Credentials>,
pub(crate) ssl: bool,
Expand Down Expand Up @@ -255,6 +263,7 @@ impl Default for ConnectionOptions {
port: 8182,
pool_size: 10,
pool_get_connection_timeout: Some(Duration::from_secs(30)),
pool_healthcheck_interval: None,
credentials: None,
ssl: false,
tls_options: None,
Expand Down

0 comments on commit 2b72a1a

Please sign in to comment.