pub struct OutboundPool { /* private fields */ }Expand description
Bounded pool of idle outbound SMTP connections.
§Thread safety
OutboundPool is Send + Sync; share it via Arc<OutboundPool>.
Implementations§
Source§impl OutboundPool
impl OutboundPool
Sourcepub fn new(config: OutboundPoolConfig, shutdown_rx: Receiver<bool>) -> Arc<Self>
pub fn new(config: OutboundPoolConfig, shutdown_rx: Receiver<bool>) -> Arc<Self>
Create a new pool and spawn the background idle-reaper task.
The reaper stops automatically when shutdown_rx yields true.
Sourcepub async fn get_or_connect(&self, remote_key: &str) -> Result<PooledConn>
pub async fn get_or_connect(&self, remote_key: &str) -> Result<PooledConn>
Obtain a connection to remote_key (format: "host:port").
If a pooled idle connection is available, returns it immediately.
Otherwise opens a new TCP connection, reads the 220 greeting, sends
EHLO localhost, reads the response, and wraps everything in a
PooledConn.
Sourcepub async fn return_conn(&self, conn: PooledConn)
pub async fn return_conn(&self, conn: PooledConn)
Return a connection to the pool after use.
Sends RSET\r\n and waits for a 250 response. On any I/O or
protocol error the connection is silently dropped. If the pool would
exceed its caps the connection is also dropped.
Sourcepub fn idle_count(&self) -> usize
pub fn idle_count(&self) -> usize
Count currently idle connections (for testing / metrics).
Auto Trait Implementations§
impl Freeze for OutboundPool
impl !RefUnwindSafe for OutboundPool
impl Send for OutboundPool
impl Sync for OutboundPool
impl Unpin for OutboundPool
impl UnsafeUnpin for OutboundPool
impl !UnwindSafe for OutboundPool
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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