mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-22 00:59:07 -05:00
improvement: reduce logging, especially for database pool size
This commit is contained in:
parent
8ea732cbe5
commit
b80b54cd9d
10
src/conn.rs
10
src/conn.rs
|
@ -5,7 +5,7 @@ use crate::error::Result;
|
|||
|
||||
use crate::subscription::Subscription;
|
||||
use std::collections::HashMap;
|
||||
use tracing::{debug, info};
|
||||
use tracing::{debug, trace};
|
||||
use uuid::Uuid;
|
||||
|
||||
/// A subscription identifier has a maximum length
|
||||
|
@ -74,7 +74,7 @@ impl ClientConn {
|
|||
// prevent arbitrarily long subscription identifiers from
|
||||
// being used.
|
||||
if sub_id_len > MAX_SUBSCRIPTION_ID_LEN {
|
||||
info!(
|
||||
debug!(
|
||||
"ignoring sub request with excessive length: ({})",
|
||||
sub_id_len
|
||||
);
|
||||
|
@ -84,7 +84,7 @@ impl ClientConn {
|
|||
if self.subscriptions.contains_key(&k) {
|
||||
self.subscriptions.remove(&k);
|
||||
self.subscriptions.insert(k, s.clone());
|
||||
debug!(
|
||||
trace!(
|
||||
"replaced existing subscription (cid: {}, sub: {:?})",
|
||||
self.get_client_prefix(),
|
||||
s.get_id()
|
||||
|
@ -98,7 +98,7 @@ impl ClientConn {
|
|||
}
|
||||
// add subscription
|
||||
self.subscriptions.insert(k, s);
|
||||
debug!(
|
||||
trace!(
|
||||
"registered new subscription, currently have {} active subs (cid: {})",
|
||||
self.subscriptions.len(),
|
||||
self.get_client_prefix(),
|
||||
|
@ -110,7 +110,7 @@ impl ClientConn {
|
|||
pub fn unsubscribe(&mut self, c: &Close) {
|
||||
// TODO: return notice if subscription did not exist.
|
||||
self.subscriptions.remove(&c.id);
|
||||
debug!(
|
||||
trace!(
|
||||
"removed subscription, currently have {} active subs (cid: {})",
|
||||
self.subscriptions.len(),
|
||||
self.get_client_prefix(),
|
||||
|
|
10
src/db.rs
10
src/db.rs
|
@ -667,13 +667,19 @@ fn _pool_at_capacity(pool: &SqlitePool) -> bool {
|
|||
state.idle_connections == 0
|
||||
}
|
||||
|
||||
/// Log pool stats
|
||||
fn log_pool_stats(name: &str, pool: &SqlitePool) {
|
||||
let state: r2d2::State = pool.state();
|
||||
let in_use_cxns = state.connections - state.idle_connections;
|
||||
debug!(
|
||||
trace!(
|
||||
"DB pool {:?} usage (in_use: {}, available: {})",
|
||||
name, in_use_cxns, state.connections
|
||||
name,
|
||||
in_use_cxns,
|
||||
state.connections
|
||||
);
|
||||
if state.connections == in_use_cxns {
|
||||
debug!("DB pool {:?} is empty (in_use: {})", name, in_use_cxns);
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform database maintenance on a regular basis
|
||||
|
|
Loading…
Reference in New Issue
Block a user