mirror of
https://github.com/telemt/telemt.git
synced 2026-11-22 15:26:37 +03:00
Rustfmt
This commit is contained in:
+3
-6
@@ -22,13 +22,13 @@ use std::sync::atomic::{AtomicBool, AtomicU8, AtomicU64, AtomicUsize, Ordering};
|
||||
use std::time::Instant;
|
||||
|
||||
pub(crate) use self::quota_store::{QuotaReservation, QuotaStore, UserQuotaHandle};
|
||||
pub(crate) use self::users::UserConnectionObservation;
|
||||
#[allow(unused_imports)]
|
||||
pub use self::replay::{ReplayChecker, ReplayStats};
|
||||
use self::telemetry::TelemetryPolicy;
|
||||
use crate::proxy::user_connection_authority::UserConnectionAuthority;
|
||||
pub use self::tls_fingerprints::TlsFingerprintSnapshotRow;
|
||||
pub(crate) use self::users::UserConnectionObservation;
|
||||
use crate::config::MeWriterPickMode;
|
||||
use crate::proxy::user_connection_authority::UserConnectionAuthority;
|
||||
|
||||
const ME_HANDSHAKE_ERROR_CODE_MAX: usize = 64;
|
||||
|
||||
@@ -432,10 +432,7 @@ impl Stats {
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn with_quota_store(quota_store: Arc<QuotaStore>) -> Self {
|
||||
Self::with_process_authorities(
|
||||
quota_store,
|
||||
Arc::new(UserConnectionAuthority::default()),
|
||||
)
|
||||
Self::with_process_authorities(quota_store, Arc::new(UserConnectionAuthority::default()))
|
||||
}
|
||||
|
||||
/// Creates generation telemetry around process-owned enforcement authorities.
|
||||
|
||||
@@ -146,11 +146,7 @@ impl QuotaStore {
|
||||
}
|
||||
|
||||
/// Advances a credential incarnation while preserving usage captured at the transition.
|
||||
pub(crate) fn advance_preserving_usage(
|
||||
&self,
|
||||
user: &str,
|
||||
incarnation: UserIncarnation,
|
||||
) {
|
||||
pub(crate) fn advance_preserving_usage(&self, user: &str, incarnation: UserIncarnation) {
|
||||
let slot = self.slot(user);
|
||||
let mut state = slot.state.lock();
|
||||
if incarnation <= state.high_water {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
use std::borrow::Borrow;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::num::NonZeroUsize;
|
||||
use std::sync::Arc;
|
||||
|
||||
+13
-12
@@ -17,26 +17,27 @@ fn test_stats_shared_counters() {
|
||||
fn runtime_stats_share_process_connection_admission_authority() {
|
||||
let quota_store = Arc::new(QuotaStore::default());
|
||||
let authority = Arc::new(UserConnectionAuthority::default());
|
||||
let first = Stats::with_process_authorities(
|
||||
Arc::clone("a_store),
|
||||
Arc::clone(&authority),
|
||||
);
|
||||
let first = Stats::with_process_authorities(Arc::clone("a_store), Arc::clone(&authority));
|
||||
let second = Stats::with_process_authorities(quota_store, authority);
|
||||
|
||||
let permit = first
|
||||
.connection_authority()
|
||||
.try_acquire("alice", Some(1))
|
||||
.unwrap();
|
||||
assert!(second
|
||||
.connection_authority()
|
||||
.try_acquire("alice", Some(1))
|
||||
.is_none());
|
||||
assert!(
|
||||
second
|
||||
.connection_authority()
|
||||
.try_acquire("alice", Some(1))
|
||||
.is_none()
|
||||
);
|
||||
|
||||
drop(permit);
|
||||
assert!(second
|
||||
.connection_authority()
|
||||
.try_acquire("alice", Some(1))
|
||||
.is_some());
|
||||
assert!(
|
||||
second
|
||||
.connection_authority()
|
||||
.try_acquire("alice", Some(1))
|
||||
.is_some()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -350,8 +350,7 @@ impl TlsFingerprintCollector {
|
||||
let mut removed = 0usize;
|
||||
self.entries.retain(|_, entry| {
|
||||
let last_seen = entry.last_seen_epoch_secs.load(Ordering::Relaxed);
|
||||
let retained =
|
||||
ttl_secs != 0 && now_epoch_secs.saturating_sub(last_seen) <= ttl_secs;
|
||||
let retained = ttl_secs != 0 && now_epoch_secs.saturating_sub(last_seen) <= ttl_secs;
|
||||
if !retained {
|
||||
removed += 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user