better_auth_diesel_sqlite/
config.rs1use std::time::Duration;
4
5#[derive(Debug, Clone)]
9pub struct PoolConfig {
10 pub max_connections: u32,
12 pub min_connections: u32,
14 pub acquire_timeout: Duration,
16 pub idle_timeout: Duration,
18 pub max_lifetime: Duration,
20 pub run_migrations: bool,
22}
23
24impl Default for PoolConfig {
25 fn default() -> Self {
26 Self {
27 max_connections: 8,
28 min_connections: 1,
29 acquire_timeout: Duration::from_secs(30),
30 idle_timeout: Duration::from_secs(600),
31 max_lifetime: Duration::from_secs(1800),
32 run_migrations: true,
33 }
34 }
35}
36
37impl PoolConfig {
38 #[must_use]
40 pub fn max_connections(mut self, n: u32) -> Self {
41 self.max_connections = n;
42 self
43 }
44
45 #[must_use]
47 pub fn min_connections(mut self, n: u32) -> Self {
48 self.min_connections = n;
49 self
50 }
51
52 #[must_use]
54 pub fn acquire_timeout(mut self, duration: Duration) -> Self {
55 self.acquire_timeout = duration;
56 self
57 }
58
59 #[must_use]
61 pub fn idle_timeout(mut self, duration: Duration) -> Self {
62 self.idle_timeout = duration;
63 self
64 }
65
66 #[must_use]
68 pub fn max_lifetime(mut self, duration: Duration) -> Self {
69 self.max_lifetime = duration;
70 self
71 }
72
73 #[must_use]
75 pub fn run_migrations(mut self, enabled: bool) -> Self {
76 self.run_migrations = enabled;
77 self
78 }
79}