pub struct ConnectionPool<S: SessionStore> { /* private fields */ }Expand description
Manages daemon connections, one active slot per session id.
Implementations§
Source§impl<S: SessionStore + 'static> ConnectionPool<S>
impl<S: SessionStore + 'static> ConnectionPool<S>
Sourcepub fn new(
daemon_url: impl Into<String>,
store: Arc<S>,
cfg: Option<PoolConfig>,
) -> Self
pub fn new( daemon_url: impl Into<String>, store: Arc<S>, cfg: Option<PoolConfig>, ) -> Self
Construct a pool for daemon_url. cfg defaults via PoolConfig::default.
Sourcepub fn with_client_factory(
self,
f: Box<dyn Fn(&str) -> Client + Send + Sync>,
) -> Self
pub fn with_client_factory( self, f: Box<dyn Fn(&str) -> Client + Send + Sync>, ) -> Self
Override the client factory (logging/metrics wrappers, test fakes).
Sourcepub fn with_bootstrap(
self,
f: impl Fn(Client, String, String, String) -> Pin<Box<dyn Future<Output = Result<String>> + Send>> + Send + Sync + 'static,
) -> Self
pub fn with_bootstrap( self, f: impl Fn(Client, String, String, String) -> Pin<Box<dyn Future<Output = Result<String>> + Send>> + Send + Sync + 'static, ) -> Self
Override loop bootstrap (loop_new + subscribe).
Sourcepub async fn acquire(
&self,
session_id: &str,
workspace_id: &str,
user_id: &str,
) -> Result<Arc<PooledConn>>
pub async fn acquire( &self, session_id: &str, workspace_id: &str, user_id: &str, ) -> Result<Arc<PooledConn>>
Acquire a live connection for session_id, bootstrapping or reattaching as needed.
The caller must call Self::release when the session connection should be torn down
(TurnRunner keeps the slot active across turns on the same session).
Sourcepub async fn release(&self, session_id: &str)
pub async fn release(&self, session_id: &str)
Tear down the connection for session_id and return a fresh slot to the pool.
Sourcepub async fn reset_session(&self, session_id: &str)
pub async fn reset_session(&self, session_id: &str)
Tear down the connection so the next acquire bootstraps fresh.
Auto Trait Implementations§
impl<S> !Freeze for ConnectionPool<S>
impl<S> !RefUnwindSafe for ConnectionPool<S>
impl<S> !UnwindSafe for ConnectionPool<S>
impl<S> Send for ConnectionPool<S>
impl<S> Sync for ConnectionPool<S>
impl<S> Unpin for ConnectionPool<S>
impl<S> UnsafeUnpin for ConnectionPool<S>
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
Mutably borrows from an owned value. Read more