1
1
//! Application-wide components in a struct accessible from each request
2
2
3
- use crate :: { db, Config , Env } ;
3
+ use crate :: db:: { ConnectionConfig , DieselPool } ;
4
+ use crate :: { Config , Env } ;
4
5
use std:: { sync:: Arc , time:: Duration } ;
5
6
6
7
use crate :: downloads_counter:: DownloadsCounter ;
@@ -18,10 +19,10 @@ use scheduled_thread_pool::ScheduledThreadPool;
18
19
#[ allow( missing_debug_implementations) ]
19
20
pub struct App {
20
21
/// The primary database connection pool
21
- pub primary_database : db :: DieselPool ,
22
+ pub primary_database : DieselPool ,
22
23
23
24
/// The read-only replica database connection pool
24
- pub read_only_replica_database : Option < db :: DieselPool > ,
25
+ pub read_only_replica_database : Option < DieselPool > ,
25
26
26
27
/// GitHub API client
27
28
pub github : GitHubClient ,
@@ -103,7 +104,7 @@ impl App {
103
104
_ => 30 ,
104
105
} ;
105
106
106
- let primary_db_connection_config = db :: ConnectionConfig {
107
+ let primary_db_connection_config = ConnectionConfig {
107
108
statement_timeout : db_connection_timeout,
108
109
read_only : config. db_primary_config . read_only_mode ,
109
110
} ;
@@ -118,11 +119,11 @@ impl App {
118
119
. thread_pool ( thread_pool. clone ( ) ) ;
119
120
120
121
let primary_database =
121
- db :: diesel_pool ( & config. db_primary_config . url , config. env , primary_db_config) ;
122
+ DieselPool :: new ( & config. db_primary_config . url , config. env , primary_db_config) ;
122
123
123
124
let replica_database = if let Some ( url) = config. db_replica_config . as_ref ( ) . map ( |c| & c. url )
124
125
{
125
- let replica_db_connection_config = db :: ConnectionConfig {
126
+ let replica_db_connection_config = ConnectionConfig {
126
127
statement_timeout : db_connection_timeout,
127
128
read_only : true ,
128
129
} ;
@@ -134,7 +135,7 @@ impl App {
134
135
. connection_customizer ( Box :: new ( replica_db_connection_config) )
135
136
. thread_pool ( thread_pool) ;
136
137
137
- Some ( db :: diesel_pool ( & url, config. env , replica_db_config) )
138
+ Some ( DieselPool :: new ( & url, config. env , replica_db_config) )
138
139
} else {
139
140
None
140
141
} ;
0 commit comments