Struct sea_orm_rocket::Config
source · pub struct Config {
pub url: String,
pub min_connections: Option<u32>,
pub max_connections: usize,
pub connect_timeout: u64,
pub idle_timeout: Option<u64>,
pub sqlx_logging: bool,
}
Expand description
Base configuration for all database drivers.
A dictionary matching this structure is extracted from the active
Figment
, scoped to databases.name
, where
name
is the name of the database, by the
Initializer
fairing on ignition and used to
configure the relevant database and database pool.
With the default provider, these parameters are typically configured in a
Rocket.toml
file:
[default.databases.db_name]
url = "/path/to/db.sqlite"
min_connections = 64
max_connections = 1024
connect_timeout = 5
idle_timeout = 120
Alternatively, a custom provider can be used. For example, a custom Figment
with a global databases.name
configuration:
#[launch]
fn rocket() -> _ {
let figment = rocket::Config::figment().merge((
"databases.name",
sea_orm_rocket::Config {
url: "db:specific@config&url".into(),
min_connections: None,
max_connections: 1024,
connect_timeout: 3,
idle_timeout: None,
sqlx_logging: true,
},
));
rocket::custom(figment)
}
For general information on configuration in Rocket, see rocket::config
.
For higher-level details on configuring a database, see the crate-level
docs.
Fields
url: String
Database-specific connection and configuration URL.
The format of the URL is database specific; consult your database’s documentation.
min_connections: Option<u32>
Minimum number of connections to maintain in the pool.
Note: deadpool
drivers do not support and thus ignore this value.
Default: None
.
max_connections: usize
Maximum number of connections to maintain in the pool.
Default: workers * 4
.
connect_timeout: u64
Number of seconds to wait for a connection before timing out.
If the timeout elapses before a connection can be made or retrieved from a pool, an error is returned.
Default: 5
.
idle_timeout: Option<u64>
Maximum number of seconds to keep a connection alive for.
After a connection is established, it is maintained in a pool for
efficient connection retrieval. When an idle_timeout
is set, that
connection will be closed after the timeout elapses. If an
idle_timeout
is not specified, the behavior is driver specific but
typically defaults to keeping a connection active indefinitely.
Default: None
.
sqlx_logging: bool
Enable SQLx statement logging (default true)
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Config
impl StructuralEq for Config
impl StructuralPartialEq for Config
Auto Trait Implementations
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
self
into a collection.