pub struct ReconnectingClient { /* private fields */ }Expand description
Reconnecting client wrapper offering automatic reconnection and leader redirection support per Architecture §21.
Implementations§
Source§impl ReconnectingClient
impl ReconnectingClient
Sourcepub async fn connect(addr: &str) -> Result<Self, ClientError>
pub async fn connect(addr: &str) -> Result<Self, ClientError>
Create a new reconnecting client
The address can be either an IP:port (e.g., “127.0.0.1:1992”) or a hostname:port (e.g., “lance.example.com:1992”).
Sourcepub fn from_existing(client: LanceClient, addr: &str) -> Self
pub fn from_existing(client: LanceClient, addr: &str) -> Self
Wrap an existing LanceClient with auto-reconnect support.
The addr is used for DNS re-resolution on reconnect (important for
load-balanced endpoints). By default, retries are unlimited.
Sourcepub async fn connect_tls(
addr: &str,
tls_config: TlsClientConfig,
) -> Result<Self, ClientError>
pub async fn connect_tls( addr: &str, tls_config: TlsClientConfig, ) -> Result<Self, ClientError>
Create a new reconnecting client with TLS
The address can be either an IP:port (e.g., “127.0.0.1:1992”) or a hostname:port (e.g., “lance.example.com:1992”).
Sourcepub fn with_max_attempts(self, attempts: u32) -> Self
pub fn with_max_attempts(self, attempts: u32) -> Self
Set maximum reconnection attempts (0 = unlimited)
Sourcepub fn with_unlimited_retries(self) -> Self
pub fn with_unlimited_retries(self) -> Self
Configure for unlimited reconnection attempts (never give up)
Sourcepub fn with_base_delay(self, delay: Duration) -> Self
pub fn with_base_delay(self, delay: Duration) -> Self
Set base delay for exponential backoff
Sourcepub fn with_max_delay(self, delay: Duration) -> Self
pub fn with_max_delay(self, delay: Duration) -> Self
Set maximum delay for exponential backoff
Sourcepub fn with_follow_leader(self, follow: bool) -> Self
pub fn with_follow_leader(self, follow: bool) -> Self
Enable or disable automatic leader following
Sourcepub fn original_addr(&self) -> &str
pub fn original_addr(&self) -> &str
Get the original connection address
Sourcepub fn leader_addr(&self) -> Option<SocketAddr>
pub fn leader_addr(&self) -> Option<SocketAddr>
Get the current leader address if known
Sourcepub fn set_leader_addr(&mut self, addr: SocketAddr)
pub fn set_leader_addr(&mut self, addr: SocketAddr)
Update the known leader address (called when redirect received)
Sourcepub fn reconnect_attempts(&self) -> u32
pub fn reconnect_attempts(&self) -> u32
Get total reconnection attempts made
Sourcepub async fn client(&mut self) -> Result<&mut LanceClient, ClientError>
pub async fn client(&mut self) -> Result<&mut LanceClient, ClientError>
Get a reference to the underlying client, reconnecting if needed
Sourcepub async fn reconnect(&mut self) -> Result<(), ClientError>
pub async fn reconnect(&mut self) -> Result<(), ClientError>
Attempt to reconnect with exponential backoff and DNS re-resolution. On success, resets the reconnect attempt counter.
Sourcepub async fn execute<F, T>(&mut self, op: F) -> Result<T, ClientError>
pub async fn execute<F, T>(&mut self, op: F) -> Result<T, ClientError>
Execute an operation with automatic reconnection on failure. Retries on all retryable errors (connection failures, FORWARD_FAILED, timeouts, backpressure, NOT_LEADER) with exponential backoff.
Sourcepub fn mark_failed(&mut self)
pub fn mark_failed(&mut self)
Mark connection as failed
Auto Trait Implementations§
impl !Freeze for ReconnectingClient
impl !RefUnwindSafe for ReconnectingClient
impl Send for ReconnectingClient
impl Sync for ReconnectingClient
impl Unpin for ReconnectingClient
impl UnsafeUnpin for ReconnectingClient
impl !UnwindSafe for ReconnectingClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request