pub struct FrankenConnectionManager { /* private fields */ }Expand description
Multi-connection manager for frankensqlite.
Provides:
- A pool of pre-opened reader connections (round-robin, Mutex-protected)
- Controlled creation of writer connections with token-based limits
- RAII guards that auto-rollback uncommitted transactions on drop
Thread-safe: reader connections are wrapped in Mutex (FrankenConnection is !Sync). Writer connections are created per-request (each thread gets its own).
Implementations§
Source§impl FrankenConnectionManager
impl FrankenConnectionManager
Sourcepub fn new(
db_path: impl Into<PathBuf>,
config: ConnectionManagerConfig,
) -> Result<Self>
pub fn new( db_path: impl Into<PathBuf>, config: ConnectionManagerConfig, ) -> Result<Self>
Create a new connection manager.
Opens config.reader_count reader connections immediately.
Writer connections are created on demand (up to config.max_writers).
Sourcepub fn reader(&self) -> MutexGuard<'_, SendFrankenConnection>
pub fn reader(&self) -> MutexGuard<'_, SendFrankenConnection>
Get a reader connection (round-robin from the pool).
Returns a mutex guard wrapping the connection. The guard prevents concurrent access to the same connection (FrankenConnection is !Sync).
Sourcepub fn writer(&self) -> Result<WriterGuard<'_>>
pub fn writer(&self) -> Result<WriterGuard<'_>>
Acquire a writer connection.
Opens a new frankensqlite connection with full config (no migration).
Blocks if max_writers connections are already in use.
The returned WriterGuard auto-rolls back on drop.
Sourcepub fn concurrent_writer(&self) -> Result<WriterGuard<'_>>
pub fn concurrent_writer(&self) -> Result<WriterGuard<'_>>
Acquire a concurrent writer connection (BEGIN CONCURRENT via MVCC).
Similar to [writer] but tuned for the parallel indexer write pool.
Uses reduced cache size and is designed for short-lived batch inserts.
Sourcepub fn reader_count(&self) -> usize
pub fn reader_count(&self) -> usize
Number of reader connections in the pool.
Sourcepub fn max_writers(&self) -> usize
pub fn max_writers(&self) -> usize
Maximum concurrent writers allowed.
Trait Implementations§
Source§impl Drop for FrankenConnectionManager
impl Drop for FrankenConnectionManager
impl Send for FrankenConnectionManager
impl Sync for FrankenConnectionManager
Auto Trait Implementations§
impl !Freeze for FrankenConnectionManager
impl !RefUnwindSafe for FrankenConnectionManager
impl Unpin for FrankenConnectionManager
impl UnsafeUnpin for FrankenConnectionManager
impl !UnwindSafe for FrankenConnectionManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> 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 more