diff --git a/neo4j/src/driver/io/bolt.rs b/neo4j/src/driver/io/bolt.rs index 320d0fe..821b8ed 100644 --- a/neo4j/src/driver/io/bolt.rs +++ b/neo4j/src/driver/io/bolt.rs @@ -240,10 +240,6 @@ impl Bolt { self.data.needs_reauth(parameters) } - pub(crate) fn current_auth(&self) -> Option> { - self.data.auth.clone() - } - #[inline] pub(crate) fn auth_reset_handler(&self) -> AuthResetHandle { AuthResetHandle::clone(&self.data.auth_reset) @@ -364,21 +360,13 @@ impl Bolt { } pub(crate) fn write_all(&mut self, deadline: Option) -> Result<()> { + self.data.idle_since = Instant::now(); self.data.write_all(deadline)?; self.data.flush(deadline) } - pub(crate) fn write_one(&mut self, deadline: Option) -> Result<()> { - self.data.write_one(deadline)?; - self.data.flush(deadline)?; - self.data.idle_since = Instant::now(); - Ok(()) - } pub(crate) fn has_buffered_message(&self) -> bool { self.data.has_buffered_message() } - pub(crate) fn buffered_messages_len(&self) -> usize { - self.data.buffered_messages_len() - } pub(crate) fn expects_reply(&self) -> bool { self.data.expects_reply() } @@ -522,7 +510,6 @@ pub(crate) struct BoltData { server_agent: Arc>>, telemetry_enabled: Arc>, address: Arc
, - address_str: String, last_qid: Arc>>, auth: Option>, session_auth: bool, @@ -539,7 +526,6 @@ impl BoltData { local_port: Option, address: Arc
, ) -> Self { - let address_str = address.to_string(); let now = Instant::now(); Self { message_buff: VecDeque::with_capacity(2048), @@ -554,7 +540,6 @@ impl BoltData { server_agent: Default::default(), telemetry_enabled: Default::default(), address, - address_str, last_qid: Default::default(), auth: None, session_auth: false, @@ -576,17 +561,6 @@ impl BoltData { self.session_auth } - fn dbg_extra(&self) -> String { - let meta = self.meta.try_borrow(); - let Ok(meta) = meta else { - return dbg_extra(self.local_port, Some("!!!!")); - }; - let Some(ValueReceive::String(id)) = meta.get("connection_id") else { - return dbg_extra(self.local_port, None); - }; - dbg_extra(self.local_port, Some(id)) - } - fn closed(&self) -> bool { !matches!(self.connection_state, ConnectionState::Healthy) } @@ -692,9 +666,6 @@ impl BoltData { fn has_buffered_message(&self) -> bool { !self.message_buff.is_empty() } - fn buffered_messages_len(&self) -> usize { - self.message_buff.len() - } fn expects_reply(&self) -> bool { !self.responses.is_empty() diff --git a/neo4j/src/driver/io/bolt/bolt4x4/protocol.rs b/neo4j/src/driver/io/bolt/bolt4x4/protocol.rs index af4ec8a..0ea4cf8 100644 --- a/neo4j/src/driver/io/bolt/bolt4x4/protocol.rs +++ b/neo4j/src/driver/io/bolt/bolt4x4/protocol.rs @@ -43,10 +43,7 @@ use super::super::{ use crate::error_::Result; use crate::value::ValueReceive; -const SERVER_AGENT_KEY: &str = "server"; const PATCH_BOLT_KEY: &str = "patch_bolt"; -const HINTS_KEY: &str = "hints"; -const RECV_TIMEOUT_KEY: &str = "connection.recv_timeout_seconds"; #[derive(Debug)] pub(crate) struct Bolt4x4 { diff --git a/neo4j/src/driver/io/bolt/bolt4x4/translator.rs b/neo4j/src/driver/io/bolt/bolt4x4/translator.rs index 8b2d0c8..f66f4c2 100644 --- a/neo4j/src/driver/io/bolt/bolt4x4/translator.rs +++ b/neo4j/src/driver/io/bolt/bolt4x4/translator.rs @@ -26,15 +26,6 @@ use crate::value::graph::{Node, Path, Relationship, UnboundRelationship}; use crate::value::time::{local_date_time_from_timestamp, FixedOffset, Tz}; use crate::value::{BrokenValue, BrokenValueInner, ValueReceive, ValueSend}; -const TAG_NODE: u8 = b'N'; -const TAG_RELATIONSHIP: u8 = b'R'; -const TAG_UNBOUND_RELATIONSHIP: u8 = b'r'; -const TAG_PATH: u8 = b'P'; -const TAG_DATE_TIME: u8 = b'I'; -const TAG_LEGACY_DATE_TIME: u8 = b'F'; -const TAG_DATE_TIME_ZONE_ID: u8 = b'i'; -const TAG_LEGACY_DATE_TIME_ZONE_ID: u8 = b'f'; - #[derive(Debug, Default)] pub(crate) struct Bolt4x4StructTranslator { utc_patch: bool, diff --git a/neo4j/src/driver/io/bolt/bolt5x1/protocol.rs b/neo4j/src/driver/io/bolt/bolt5x1/protocol.rs index 466181e..b3e6fa4 100644 --- a/neo4j/src/driver/io/bolt/bolt5x1/protocol.rs +++ b/neo4j/src/driver/io/bolt/bolt5x1/protocol.rs @@ -40,13 +40,8 @@ use crate::driver::config::auth::AuthToken; use crate::error_::Result; use crate::value::ValueReceive; -const SERVER_AGENT_KEY: &str = "server"; -const HINTS_KEY: &str = "hints"; -const RECV_TIMEOUT_KEY: &str = "connection.recv_timeout_seconds"; - #[derive(Debug)] pub(crate) struct Bolt5x1 { - translator: T, pub(in super::super) bolt5x0: Bolt5x0, protocol_version: ServerAwareBoltVersion, } @@ -54,7 +49,6 @@ pub(crate) struct Bolt5x1 { impl Bolt5x1 { pub(in super::super) fn new(protocol_version: ServerAwareBoltVersion) -> Self { Self { - translator: T::default(), bolt5x0: Bolt5x0::new(T::default(), protocol_version), protocol_version, } diff --git a/neo4j/src/driver/io/bolt/bolt5x2/protocol.rs b/neo4j/src/driver/io/bolt/bolt5x2/protocol.rs index da23a71..fd2e475 100644 --- a/neo4j/src/driver/io/bolt/bolt5x2/protocol.rs +++ b/neo4j/src/driver/io/bolt/bolt5x2/protocol.rs @@ -39,15 +39,10 @@ use super::super::{ use crate::error_::Result; use crate::value::ValueReceive; -const SERVER_AGENT_KEY: &str = "server"; -const HINTS_KEY: &str = "hints"; -const RECV_TIMEOUT_KEY: &str = "connection.recv_timeout_seconds"; - #[derive(Debug)] pub(crate) struct Bolt5x2 { translator: T, pub(in super::super) bolt5x1: Bolt5x1, - protocol_version: ServerAwareBoltVersion, } impl Bolt5x2 { @@ -55,7 +50,6 @@ impl Bolt5x2 { Self { translator: T::default(), bolt5x1: Bolt5x1::new(protocol_version), - protocol_version, } } diff --git a/neo4j/src/driver/io/bolt/bolt5x3/protocol.rs b/neo4j/src/driver/io/bolt/bolt5x3/protocol.rs index 9414480..a93a884 100644 --- a/neo4j/src/driver/io/bolt/bolt5x3/protocol.rs +++ b/neo4j/src/driver/io/bolt/bolt5x3/protocol.rs @@ -40,23 +40,15 @@ use super::super::{ use crate::error_::Result; use crate::value::ValueReceive; -const SERVER_AGENT_KEY: &str = "server"; -const HINTS_KEY: &str = "hints"; -const RECV_TIMEOUT_KEY: &str = "connection.recv_timeout_seconds"; - #[derive(Debug)] pub(crate) struct Bolt5x3 { - translator: T, pub(in super::super) bolt5x2: Bolt5x2, - protocol_version: ServerAwareBoltVersion, } impl Bolt5x3 { pub(in super::super) fn new(protocol_version: ServerAwareBoltVersion) -> Self { Self { - translator: T::default(), bolt5x2: Bolt5x2::new(protocol_version), - protocol_version, } } diff --git a/neo4j/src/driver/io/bolt/bolt_common.rs b/neo4j/src/driver/io/bolt/bolt_common.rs index e94ab13..f6bb13d 100644 --- a/neo4j/src/driver/io/bolt/bolt_common.rs +++ b/neo4j/src/driver/io/bolt/bolt_common.rs @@ -111,6 +111,7 @@ pub(super) enum ServerAwareBoltVersion { V5x1, V5x2, V5x3, + #[allow(dead_code)] // bolt version exists, not yet implemented V5x4, } diff --git a/neo4j/src/driver/io/bolt/response.rs b/neo4j/src/driver/io/bolt/response.rs index a99a86c..c0ca75e 100644 --- a/neo4j/src/driver/io/bolt/response.rs +++ b/neo4j/src/driver/io/bolt/response.rs @@ -74,16 +74,6 @@ impl ResponseCallbacks { .with_on_failure(|error| Err(error.into())) } - pub(crate) fn new_silent_error() -> Self { - Self { - on_success_cb: None, - on_failure_cb: None, - on_ignored_cb: None, - on_record_cb: None, - on_summary_cb: None, - } - } - pub(crate) fn with_on_success Result<()> + Send + Sync + 'static>( mut self, cb: F, @@ -136,11 +126,6 @@ impl ResponseCallbacks { self } - pub(crate) fn with_on_summary(mut self, cb: F) -> Self { - self.on_summary_cb = Some(Box::new(cb)); - self - } - pub(crate) fn on_success(&mut self, meta: ValueReceive) -> Result<()> { let res = match meta { ValueReceive::Map(meta) => match self.on_success_cb.as_mut() { diff --git a/neo4j/src/driver/io/bolt/socket.rs b/neo4j/src/driver/io/bolt/socket.rs index c0d7601..99801e2 100644 --- a/neo4j/src/driver/io/bolt/socket.rs +++ b/neo4j/src/driver/io/bolt/socket.rs @@ -151,20 +151,6 @@ impl Socket { } }) } - - pub(super) fn io_ref(&self) -> &T { - match self { - Socket::Plain(io) => io, - Socket::Tls(io) => io.get_ref(), - } - } - - pub(super) fn io_mut(&mut self) -> &mut T { - match self { - Socket::Plain(io) => io, - Socket::Tls(io) => io.get_mut(), - } - } } impl Read for Socket { diff --git a/neo4j/src/driver/io/deadline.rs b/neo4j/src/driver/io/deadline.rs index 89cc03b..6831140 100644 --- a/neo4j/src/driver/io/deadline.rs +++ b/neo4j/src/driver/io/deadline.rs @@ -14,40 +14,13 @@ use log::warn; use std::fmt::Debug; -use std::io::{self, ErrorKind, Read, Write}; +use std::io::{self, Read, Write}; use std::net::TcpStream; use std::time::Duration; use crate::error_::{Neo4jError, Result}; use crate::time::Instant; -pub(crate) fn rewrite_timeout Result>(f: F) -> Result { - match f() { - Err(Neo4jError::Disconnect { - message, - source: Some(io_err), - during_commit, - }) => { - let kind = io_err.kind(); - match kind { - ErrorKind::WouldBlock | ErrorKind::TimedOut => { - assert!( - !during_commit, - "tried to rewrite io error to timeout error during commit" - ); - Err(Neo4jError::Timeout { message }) - } - _ => Err(Neo4jError::Disconnect { - message, - source: Some(io_err), - during_commit, - }), - } - } - v => v, - } -} - fn wrap_set_timeout_error(e: Result) -> Result { match e { Ok(t) => Ok(t), diff --git a/neo4j/src/driver/io/pool.rs b/neo4j/src/driver/io/pool.rs index 5ba00ae..47d1936 100644 --- a/neo4j/src/driver/io/pool.rs +++ b/neo4j/src/driver/io/pool.rs @@ -100,11 +100,6 @@ impl<'pool> PooledBolt<'pool> { move |bolt_data, error| pool.handle_server_error(bolt_data, error) } - #[inline] - pub(crate) fn write_one(&mut self, deadline: Option) -> Result<()> { - self.wrap_io(|this| this.deref_mut().write_one(deadline)) - } - #[inline] pub(crate) fn write_all(&mut self, deadline: Option) -> Result<()> { self.wrap_io(|this| this.deref_mut().write_all(deadline)) @@ -175,7 +170,6 @@ impl PoolConfig { #[derive(Debug)] pub(crate) struct Pool { - address: Arc
, config: Arc, pools: Pools, } @@ -183,12 +177,8 @@ pub(crate) struct Pool { impl Pool { pub(crate) fn new(address: Arc
, config: PoolConfig) -> Self { let config = Arc::new(config); - let pools = Pools::new(Arc::clone(&address), Arc::clone(&config)); - Self { - address, - config, - pools, - } + let pools = Pools::new(address, Arc::clone(&config)); + Self { config, pools } } #[inline] @@ -207,12 +197,6 @@ impl Pool { self.pools.get_metrics(address) } - pub(crate) fn default_acquisition_deadline(&self) -> Option { - self.config - .connection_acquisition_timeout - .map(|t| Instant::now() + t) - } - pub(crate) fn resolve_home_db(&self, args: UpdateRtArgs) -> Result>> { let Pools::Routing(pools) = &self.pools else { panic!("don't call resolve_home_db on a direct pool") @@ -276,12 +260,6 @@ impl Pool { routing_pool.deactivate_server(addr) } } - - fn deactivate_writer(&self, addr: &Address) { - if let Pools::Routing(routing_pool) = &self.pools { - routing_pool.deactivate_writer(addr) - } - } } #[derive(Debug)] @@ -304,14 +282,6 @@ impl Pools { } } - pub(crate) fn is_routing(&self) -> bool { - matches!(self, Pools::Routing(_)) - } - - pub(crate) fn is_direct(&self) -> bool { - matches!(self, Pools::Direct(_)) - } - #[cfg(feature = "_internal_testkit_backend")] fn get_metrics(&self, address: Arc
) -> Option { match self { @@ -868,28 +838,3 @@ pub(crate) struct UpdateRtArgs<'a> { pub(crate) session_auth: SessionAuth<'a>, pub(crate) idle_time_before_connection_test: Option, } - -enum DbName<'a> { - Ref(&'a Option), - Owned(Option), -} - -impl<'a> Deref for DbName<'a> { - type Target = Option; - - fn deref(&self) -> &Self::Target { - match self { - DbName::Ref(s) => s, - DbName::Owned(s) => s, - } - } -} - -impl<'a> DbName<'a> { - fn into_key(self) -> Option { - match self { - DbName::Ref(s) => s.clone(), - DbName::Owned(s) => s, - } - } -} diff --git a/neo4j/src/driver/io/pool/routing.rs b/neo4j/src/driver/io/pool/routing.rs index 9bbcf56..fe37cf1 100644 --- a/neo4j/src/driver/io/pool/routing.rs +++ b/neo4j/src/driver/io/pool/routing.rs @@ -182,10 +182,6 @@ impl RoutingTable { true } - pub(crate) fn initialized_without_writers(&self) -> bool { - self.initialized_without_writers - } - pub(crate) fn deactivate(&mut self, addr: &Address) { self.routers = mem::take(&mut self.routers) .into_iter() diff --git a/neo4j/src/driver/io/pool/single_pool.rs b/neo4j/src/driver/io/pool/single_pool.rs index 92d0d2c..4c2d32e 100644 --- a/neo4j/src/driver/io/pool/single_pool.rs +++ b/neo4j/src/driver/io/pool/single_pool.rs @@ -227,12 +227,6 @@ impl SimplePool { Some(UnpreparedSinglePooledBolt::new(None, Arc::clone(&self.0))) } - pub(crate) fn acquire_idle(&self) -> Option { - let mut synced = self.synced.lock(); - self.acquire_existing(&mut synced) - .map(|connection| SinglePooledBolt::new(connection, Arc::clone(&self.0))) - } - pub(crate) fn in_use(&self) -> usize { let synced = self.synced.lock(); synced.borrowed + synced.reservations @@ -331,7 +325,7 @@ impl UnpreparedSinglePooledBolt { Some(mut connection) => { // room for health check etc. (return None on failed health check) if let Some(max_lifetime) = self.pool.config.max_connection_lifetime { - if connection.is_idle_for(max_lifetime) { + if connection.is_older_than(max_lifetime) { connection.debug_log(|| String::from("connection reached max lifetime")); connection.close(); return Ok(None); diff --git a/neo4j/src/driver/record_stream.rs b/neo4j/src/driver/record_stream.rs index b9cb6b1..85eee81 100644 --- a/neo4j/src/driver/record_stream.rs +++ b/neo4j/src/driver/record_stream.rs @@ -454,6 +454,7 @@ enum RecordListenerState { } impl RecordListenerState { + #[allow(dead_code)] // cover all states #[duplicate_item( fn_name variant; [ is_streaming ] [ Streaming ]; @@ -604,10 +605,6 @@ pub(crate) struct ErrorPropagator { pub(crate) type SharedErrorPropagator = Arc>; impl ErrorPropagator { - pub(crate) fn new() -> Self { - Self::default() - } - fn add_listener(&mut self, listener: Weak>) { if let Some(error) = &self.error { if let Some(listener) = listener.upgrade() { diff --git a/neo4j/src/driver/session/bookmarks.rs b/neo4j/src/driver/session/bookmarks.rs index 4ea47ed..7c71061 100644 --- a/neo4j/src/driver/session/bookmarks.rs +++ b/neo4j/src/driver/session/bookmarks.rs @@ -30,8 +30,6 @@ use crate::driver::ExecuteQueryBuilder; use crate::session::SessionConfig; type BoxError = Box; -type SupplierFn = Box StdResult, BoxError> + Send + Sync>; -type ConsumerFn = Box) -> StdResult<(), BoxError> + Send + Sync>; /// Container for bookmarks that can be used to build a [causal chain](crate#causal-consistency). /// @@ -76,14 +74,6 @@ impl Bookmarks { } } - /// Creates a new [`Bookmarks`] containing no bookmarks. - /// - /// This is equivalent to [`Bookmarks::default()`]. - #[inline] - pub(crate) fn empty() -> Self { - Default::default() - } - /// Return the count of contained bookmarks. pub fn len(&self) -> usize { self.bookmarks.len() @@ -436,46 +426,6 @@ pub mod bookmark_managers { } } - impl Neo4jBookmarkManager { - pub fn new() -> Self { - Self { - bookmarks: Default::default(), - supplier: None, - consumer: None, - } - } - - pub fn with_bookmarks(bookmarks: Arc) -> Self { - Neo4jBookmarkManager { - bookmarks: RwLock::new(bookmarks), - supplier: None, - consumer: None, - } - } - - pub fn with_bookmark_supplier(self, supplier: SF2) -> Neo4jBookmarkManager - where - SF2: Fn() -> StdResult, BoxError> + Send + Sync + 'static, - { - Neo4jBookmarkManager { - bookmarks: self.bookmarks, - supplier: Some(supplier), - consumer: self.consumer, - } - } - - pub fn with_bookmark_consumer(self, consumer: CF2) -> Neo4jBookmarkManager - where - CF2: Fn(Arc) -> StdResult<(), BoxError> + Send + Sync + 'static, - { - Neo4jBookmarkManager { - bookmarks: self.bookmarks, - supplier: self.supplier, - consumer: Some(consumer), - } - } - } - impl BookmarkManager for Neo4jBookmarkManager where SF: Fn() -> StdResult, BoxError> + Send + Sync + 'static, diff --git a/neo4j/src/error_.rs b/neo4j/src/error_.rs index 383dcda..eda386a 100644 --- a/neo4j/src/error_.rs +++ b/neo4j/src/error_.rs @@ -233,13 +233,6 @@ impl Neo4jError { _ => false, } } - - pub(crate) fn invalidates_writer(&self) -> bool { - match self { - Neo4jError::ServerError { error } => error.invalidates_writer(), - _ => false, - } - } } #[derive(Debug)] diff --git a/neo4j/src/lib.rs b/neo4j/src/lib.rs index 88c3a26..da03900 100644 --- a/neo4j/src/lib.rs +++ b/neo4j/src/lib.rs @@ -13,8 +13,6 @@ // limitations under the License. #![allow(clippy::option_map_unit_fn)] -// TODO: remove when prototyping phase is done -#![allow(dead_code)] //! # Neo4j Bolt Driver //! @@ -233,14 +231,6 @@ pub mod transaction { pub use super::driver::transaction::*; } -// TODO: decide if this concept should remain -#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] -enum Database<'a> { - Named(&'a str), - UnresolvedHome, - ResolvedHome, -} - mod private { // Trait to prevent traits from being implemented outside of this crate. pub trait Sealed {} diff --git a/neo4j/src/sync.rs b/neo4j/src/sync.rs index 3dcb024..1f01e7a 100644 --- a/neo4j/src/sync.rs +++ b/neo4j/src/sync.rs @@ -27,6 +27,7 @@ pub(crate) struct MostlyRLock { updating: AtomicBool, } +#[allow(dead_code)] // unused methods for symetry between read and write ops impl MostlyRLock { pub(crate) fn new(inner: T) -> Self { let inner = RwLock::new(inner); diff --git a/neo4j/src/time.rs b/neo4j/src/time.rs index 6941837..8a1f2a4 100644 --- a/neo4j/src/time.rs +++ b/neo4j/src/time.rs @@ -45,6 +45,7 @@ impl AddAssign for Instant { } } +#[allow(dead_code)] // make API more consistent between feature flags impl Instant { #[inline] pub fn new(inner: StdInstant) -> Self { diff --git a/neo4j/src/util.rs b/neo4j/src/util.rs index cbf60fe..b11ffc9 100644 --- a/neo4j/src/util.rs +++ b/neo4j/src/util.rs @@ -12,14 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::any::type_name; - -/// until (type_name_of_val)[https://doc.rust-lang.org/std/any/fn.type_name_of_val.html] -/// becomes stable, we'll do it on our own =) -pub(crate) fn get_type_name(_: T) -> &'static str { - type_name::() -} - pub(crate) fn truncate_string(string: &str, start: usize, end: usize) -> &str { let mut chars = string.chars(); for _ in 0..start { diff --git a/neo4j/src/value/value_receive.rs b/neo4j/src/value/value_receive.rs index 9722350..571029f 100644 --- a/neo4j/src/value/value_receive.rs +++ b/neo4j/src/value/value_receive.rs @@ -794,12 +794,6 @@ impl From for BrokenValue { } } -pub(crate) fn broken_value(reason: impl Into) -> ValueReceive { - ValueReceive::BrokenValue(BrokenValue { - inner: BrokenValueInner::Reason(reason.into()), - }) -} - impl ValueReceive { pub(crate) fn dbg_print(&self) -> String { match self {