Skip to content

Commit 95d8ed5

Browse files
committed
app: Remove obsolete DieselPool fields
These are no longer used anywhere in our codebase.
1 parent bdc8404 commit 95d8ed5

File tree

1 file changed

+1
-65
lines changed

1 file changed

+1
-65
lines changed

src/app.rs

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Application-wide components in a struct accessible from each request
22
33
use crate::config;
4-
use crate::db::{connection_url, ConnectionConfig, DieselPool};
4+
use crate::db::{connection_url, ConnectionConfig};
55
use std::ops::Deref;
66
use std::sync::atomic::AtomicUsize;
77
use std::sync::Arc;
@@ -14,25 +14,17 @@ use axum::extract::{FromRef, FromRequestParts, State};
1414
use crates_io_github::GitHubClient;
1515
use deadpool_diesel::postgres::{Manager as DeadpoolManager, Pool as DeadpoolPool};
1616
use deadpool_diesel::Runtime;
17-
use diesel::r2d2;
1817
use oauth2::basic::BasicClient;
19-
use scheduled_thread_pool::ScheduledThreadPool;
2018

2119
type DeadpoolResult = Result<deadpool_diesel::postgres::Connection, deadpool_diesel::PoolError>;
2220

2321
/// The `App` struct holds the main components of the application like
2422
/// the database connection pool and configurations
2523
pub struct App {
26-
/// The primary database connection pool
27-
pub primary_database: DieselPool,
28-
2924
/// Async database connection pool based on `deadpool` connected
3025
/// to the primary database
3126
pub deadpool_primary: DeadpoolPool,
3227

33-
/// The read-only replica database connection pool
34-
pub read_only_replica_database: Option<DieselPool>,
35-
3628
/// Async database connection pool based on `deadpool` connected
3729
/// to the read-only replica database
3830
pub deadpool_replica: Option<DeadpoolPool>,
@@ -88,32 +80,6 @@ impl App {
8880
),
8981
);
9082

91-
let thread_pool = Arc::new(ScheduledThreadPool::new(config.db.helper_threads));
92-
93-
let primary_database = {
94-
let primary_db_connection_config = ConnectionConfig {
95-
statement_timeout: config.db.statement_timeout,
96-
read_only: config.db.primary.read_only_mode,
97-
};
98-
99-
let primary_db_config = r2d2::Pool::builder()
100-
.max_size(config.db.primary.pool_size)
101-
.min_idle(config.db.primary.min_idle)
102-
.connection_timeout(config.db.connection_timeout)
103-
.connection_customizer(Box::new(primary_db_connection_config))
104-
.thread_pool(thread_pool.clone());
105-
106-
DieselPool::new(
107-
&config.db.primary.url,
108-
&config.db,
109-
primary_db_config,
110-
instance_metrics
111-
.database_time_to_obtain_connection
112-
.with_label_values(&["primary"]),
113-
)
114-
.unwrap()
115-
};
116-
11783
let primary_database_async = {
11884
use secrecy::ExposeSecret;
11985

@@ -134,34 +100,6 @@ impl App {
134100
.unwrap()
135101
};
136102

137-
let replica_database = if let Some(pool_config) = config.db.replica.as_ref() {
138-
let replica_db_connection_config = ConnectionConfig {
139-
statement_timeout: config.db.statement_timeout,
140-
read_only: pool_config.read_only_mode,
141-
};
142-
143-
let replica_db_config = r2d2::Pool::builder()
144-
.max_size(pool_config.pool_size)
145-
.min_idle(pool_config.min_idle)
146-
.connection_timeout(config.db.connection_timeout)
147-
.connection_customizer(Box::new(replica_db_connection_config))
148-
.thread_pool(thread_pool);
149-
150-
Some(
151-
DieselPool::new(
152-
&pool_config.url,
153-
&config.db,
154-
replica_db_config,
155-
instance_metrics
156-
.database_time_to_obtain_connection
157-
.with_label_values(&["follower"]),
158-
)
159-
.unwrap(),
160-
)
161-
} else {
162-
None
163-
};
164-
165103
let replica_database_async = if let Some(pool_config) = config.db.replica.as_ref() {
166104
use secrecy::ExposeSecret;
167105

@@ -187,9 +125,7 @@ impl App {
187125
};
188126

189127
App {
190-
primary_database,
191128
deadpool_primary: primary_database_async,
192-
read_only_replica_database: replica_database,
193129
deadpool_replica: replica_database_async,
194130
github,
195131
github_oauth,

0 commit comments

Comments
 (0)