From 2b72a1ada590822d65445adb65d84dd6582ca803 Mon Sep 17 00:00:00 2001 From: Allan Clements Date: Mon, 26 Aug 2024 19:13:12 -0500 Subject: [PATCH] Expose healthcheck interval setting on async connection pool --- gremlin-client/src/aio/client.rs | 1 + gremlin-client/src/connection.rs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/gremlin-client/src/aio/client.rs b/gremlin-client/src/aio/client.rs index c2f7a727..fcaa4c47 100644 --- a/gremlin-client/src/aio/client.rs +++ b/gremlin-client/src/aio/client.rs @@ -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 { diff --git a/gremlin-client/src/connection.rs b/gremlin-client/src/connection.rs index c8072ab5..dff7857f 100644 --- a/gremlin-client/src/connection.rs +++ b/gremlin-client/src/connection.rs @@ -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) -> 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) -> Self { @@ -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, pub(crate) pool_get_connection_timeout: Option, pub(crate) credentials: Option, pub(crate) ssl: bool, @@ -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,