pub struct Builder { /* private fields */ }sqlsrv only.Expand description
Builder for constructing a ConnPool object.
Implementations§
impl Builder
Internal methods.
Source§impl Builder
impl Builder
Sourcepub fn new(schmgr: Box<dyn SchemaMgr>) -> Builder
pub fn new(schmgr: Box<dyn SchemaMgr>) -> Builder
Create a new Builder for constructing a ConnPool object.
Default to not run a full vacuum of the database on initialization and create 2 read-only connections for the pool. No workers thread pool will be used.
Sourcepub const fn init_vacuum(self) -> Builder
pub const fn init_vacuum(self) -> Builder
Trigger a full vacuum when initializing the connection pool.
Operates on an owned Builder object.
Sourcepub const fn init_vacuum_r(&mut self) -> &mut Builder
pub const fn init_vacuum_r(&mut self) -> &mut Builder
Trigger a full vacuum when initializing the connection pool.
Operates on a borrowed Builder object.
Sourcepub const fn max_readers(self, n: usize) -> Builder
pub const fn max_readers(self, n: usize) -> Builder
Set maximum number of readers in the connection pool.
Operates on an owned Builder object.
Sourcepub const fn max_readers_r(&mut self, n: usize) -> &mut Builder
pub const fn max_readers_r(&mut self, n: usize) -> &mut Builder
Set maximum number of readers in the connection pool.
Operates on a borrowed Builder object.
Sourcepub fn hook(self, hook: Arc<dyn Hook + Send + Sync>) -> Builder
pub fn hook(self, hook: Arc<dyn Hook + Send + Sync>) -> Builder
Request that a “raw” update hook be added to the writer connection.
Operates on an owned Builder object.
Sourcepub fn hook_r(&mut self, hook: Arc<dyn Hook + Send + Sync>) -> &mut Builder
pub fn hook_r(&mut self, hook: Arc<dyn Hook + Send + Sync>) -> &mut Builder
Request that a “raw” update hook be added to the writer connection.
Operates on a borrowed Builder object.
Sourcepub const fn incremental_autoclean(
self,
dirt_watermark: usize,
npages: Option<NonZero<usize>>,
) -> Builder
pub const fn incremental_autoclean( self, dirt_watermark: usize, npages: Option<NonZero<usize>>, ) -> Builder
Enable incremental autovacuum.
dirt_watermark is used to set what amount of “dirt” is required in
order to trigger an autoclean. nfree is the number of blocks in the
freelists to process each time the autoclean is run.
Sourcepub fn reg_scalar_fn<F>(self, r: RegOn<F>) -> Builder
pub fn reg_scalar_fn<F>(self, r: RegOn<F>) -> Builder
Add a callback to register one or more scalar SQL functions.
The closure should be wrapped in a RegOn::RO() if the function should
only be registered on read-only connections. RegOn::RW() is used to
register the function on the read/write connection. Use RegOn::Both()
to register in both read-only and the read/write connection.
Sourcepub fn reg_scalar_fn_r<F>(&mut self, r: RegOn<F>) -> &mut Builder
pub fn reg_scalar_fn_r<F>(&mut self, r: RegOn<F>) -> &mut Builder
Add a callback to register one or more scalar SQL functions.
This is the same as Builder::reg_scalar_fn(), but it operates on
&mut Builder rather than passing ownership.
pub fn thread_pool(self, tpool: Arc<ThreadPool>) -> Builder
pub fn thread_pool_r(&mut self, tpool: Arc<ThreadPool>) -> &mut Builder
Sourcepub fn build_with_changelog_hook<P, D, T>(
self,
fname: P,
hook: Box<dyn ChangeLogHook<Table = T, Database = D> + Send>,
) -> Result<ConnPool, Error>
pub fn build_with_changelog_hook<P, D, T>( self, fname: P, hook: Box<dyn ChangeLogHook<Table = T, Database = D> + Send>, ) -> Result<ConnPool, Error>
Construct a connection pool.
Same as Builder::build(), but register a change log callback on the
writer as well.
This method should not be called if the application has requested to add a raw update hook.
§Errors
Error::Sqlite is returned for database errors.
§Panics
This method will panic if a hook has been added to the Builder.