Skip to content

Commit bdc8404

Browse files
committed
app: Remove obsolete db_*() fns
These functions are no longer used anywhere in our codebase.
1 parent 99a6f00 commit bdc8404

File tree

1 file changed

+1
-66
lines changed

1 file changed

+1
-66
lines changed

src/app.rs

Lines changed: 1 addition & 66 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, DieselPooledConn, PoolError};
4+
use crate::db::{connection_url, ConnectionConfig, DieselPool};
55
use std::ops::Deref;
66
use std::sync::atomic::AtomicUsize;
77
use std::sync::Arc;
@@ -208,48 +208,12 @@ impl App {
208208
&self.config.session_key
209209
}
210210

211-
/// Obtain a read/write database connection from the primary pool
212-
#[instrument(skip_all)]
213-
pub fn db_write(&self) -> Result<DieselPooledConn, PoolError> {
214-
self.primary_database.get()
215-
}
216-
217211
/// Obtain a read/write database connection from the async primary pool
218212
#[instrument(skip_all)]
219213
pub async fn db_write_async(&self) -> DeadpoolResult {
220214
self.deadpool_primary.get().await
221215
}
222216

223-
/// Obtain a readonly database connection from the replica pool
224-
///
225-
/// If the replica pool is disabled or unavailable, the primary pool is used instead.
226-
#[instrument(skip_all)]
227-
pub fn db_read(&self) -> Result<DieselPooledConn, PoolError> {
228-
let Some(read_only_pool) = self.read_only_replica_database.as_ref() else {
229-
// Replica is disabled, but primary might be available
230-
return self.primary_database.get();
231-
};
232-
233-
match read_only_pool.get() {
234-
// Replica is available
235-
Ok(connection) => Ok(connection),
236-
237-
// Replica is not available, but primary might be available
238-
Err(PoolError::UnhealthyPool) => {
239-
let _ = self
240-
.instance_metrics
241-
.database_fallback_used
242-
.get_metric_with_label_values(&["follower"])
243-
.map(|metric| metric.inc());
244-
245-
self.primary_database.get()
246-
}
247-
248-
// Replica failed
249-
Err(error) => Err(error),
250-
}
251-
}
252-
253217
/// Obtain a readonly database connection from the replica pool
254218
///
255219
/// If the replica pool is disabled or unavailable, the primary pool is used instead.
@@ -281,35 +245,6 @@ impl App {
281245
}
282246
}
283247

284-
/// Obtain a readonly database connection from the primary pool
285-
///
286-
/// If the primary pool is unavailable, the replica pool is used instead, if not disabled.
287-
#[instrument(skip_all)]
288-
pub fn db_read_prefer_primary(&self) -> Result<DieselPooledConn, PoolError> {
289-
let Some(read_only_pool) = self.read_only_replica_database.as_ref() else {
290-
return self.primary_database.get();
291-
};
292-
293-
match self.primary_database.get() {
294-
// Primary is available
295-
Ok(connection) => Ok(connection),
296-
297-
// Primary is not available, but replica might be available
298-
Err(PoolError::UnhealthyPool) => {
299-
let _ = self
300-
.instance_metrics
301-
.database_fallback_used
302-
.get_metric_with_label_values(&["primary"])
303-
.map(|metric| metric.inc());
304-
305-
read_only_pool.get()
306-
}
307-
308-
// Primary failed
309-
Err(error) => Err(error),
310-
}
311-
}
312-
313248
/// Obtain a readonly database connection from the primary pool
314249
///
315250
/// If the primary pool is unavailable, the replica pool is used instead, if not disabled.

0 commit comments

Comments
 (0)