Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iambriccardo committed Jul 18, 2024
1 parent e2ca3d4 commit 05b1317
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion relay-server/src/endpoints/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ fn queue_envelope(
let scoping = managed_envelope.scoping();
let envelopes = ProcessingGroup::split_envelope(*managed_envelope.take_envelope());
for (group, envelope) in envelopes {
let envelope = ManagedEnvelope::new(
let mut envelope = ManagedEnvelope::new(
envelope,
state.outcome_aggregator().clone(),
state.test_store().clone(),
Expand Down
6 changes: 3 additions & 3 deletions relay-server/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl ServiceState {
);
ProjectCacheService::new(
config.clone(),
memory_stat.with_config(config.clone()),
memory_stat.init_checker(config.clone()),
project_cache_services,
metric_outcomes,
redis_pool.clone(),
Expand All @@ -211,7 +211,7 @@ impl ServiceState {

let health_check = HealthCheckService::new(
config.clone(),
memory_stat.with_config(config.clone()),
memory_stat.init_checker(config.clone()),
aggregator.clone(),
upstream_relay.clone(),
project_cache.clone(),
Expand Down Expand Up @@ -243,7 +243,7 @@ impl ServiceState {

let state = StateInner {
config: config.clone(),
memory_checker: memory_stat.with_config(config),
memory_checker: memory_stat.init_checker(config),
registry,
};

Expand Down
6 changes: 2 additions & 4 deletions relay-server/src/services/project_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ use crate::services::test_store::TestStore;
use crate::services::upstream::UpstreamRelay;

use crate::statsd::{RelayCounters, RelayGauges, RelayHistograms, RelayTimers};
use crate::utils::{
self, GarbageDisposal, ManagedEnvelope, MemoryChecker, RetryBackoff, SleepHandle,
};
use crate::utils::{GarbageDisposal, ManagedEnvelope, MemoryChecker, RetryBackoff, SleepHandle};

/// Requests a refresh of a project state from one of the available sources.
///
Expand Down Expand Up @@ -1297,7 +1295,7 @@ mod tests {
}))
.unwrap()
.into();
let memory_checker = MemoryStat::new().with_config(config.clone());
let memory_checker = MemoryStat::new().init_checker(config.clone());
let buffer_services = spooler::Services {
outcome_aggregator: services.outcome_aggregator.clone(),
project_cache: services.project_cache.clone(),
Expand Down
14 changes: 7 additions & 7 deletions relay-server/src/services/spooler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ mod tests {
}))
.unwrap()
.into();
let memory_checker = MemoryStat::new().with_config(config.clone());
let memory_checker = MemoryStat::new().init_checker(config.clone());
BufferService::create(memory_checker, services(), config)
.await
.unwrap();
Expand All @@ -1392,7 +1392,7 @@ mod tests {
}))
.unwrap()
.into();
let memory_checker = MemoryStat::new().with_config(config.clone());
let memory_checker = MemoryStat::new().init_checker(config.clone());
let service = BufferService::create(memory_checker, services(), config)
.await
.unwrap();
Expand Down Expand Up @@ -1463,7 +1463,7 @@ mod tests {
}))
.unwrap()
.into();
let memory_checker = MemoryStat::new().with_config(config.clone());
let memory_checker = MemoryStat::new().init_checker(config.clone());
let project_key = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fee").unwrap();
let key = QueueKey {
own_key: project_key,
Expand Down Expand Up @@ -1611,7 +1611,7 @@ mod tests {
}))
.unwrap()
.into();
let memory_checker = MemoryStat::new().with_config(config.clone());
let memory_checker = MemoryStat::new().init_checker(config.clone());

let buffer = BufferService::create(memory_checker, services(), config)
.await
Expand Down Expand Up @@ -1642,7 +1642,7 @@ mod tests {
}))
.unwrap()
.into();
let memory_checker = MemoryStat::new().with_config(config.clone());
let memory_checker = MemoryStat::new().init_checker(config.clone());

let buffer = BufferService::create(memory_checker, services(), config)
.await
Expand Down Expand Up @@ -1675,7 +1675,7 @@ mod tests {
}))
.unwrap()
.into();
let memory_checker = MemoryStat::new().with_config(config.clone());
let memory_checker = MemoryStat::new().init_checker(config.clone());

// Setup spool file and run migrations.
BufferService::setup(&db_path).await.unwrap();
Expand Down Expand Up @@ -1754,7 +1754,7 @@ mod tests {
}))
.unwrap()
.into();
let memory_checker = MemoryStat::new().with_config(config.clone());
let memory_checker = MemoryStat::new().init_checker(config.clone());

let services = services();
let buffer = BufferService::create(memory_checker, services, config)
Expand Down
6 changes: 3 additions & 3 deletions relay-server/src/utils/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl MemoryStat {

/// Builds a [`MemoryChecker`] which holds a reference to the supplied [`Config`] and the
/// current [`MemoryStat`].
pub fn with_config(&self, config: Arc<Config>) -> MemoryChecker {
pub fn init_checker(&self, config: Arc<Config>) -> MemoryChecker {
MemoryChecker {
memory_stat: self.clone(),
config,
Expand Down Expand Up @@ -279,7 +279,7 @@ mod tests {
}
}))
.unwrap();
let memory_checker = MemoryStat::new().with_config(Arc::new(config));
let memory_checker = MemoryStat::new().init_checker(Arc::new(config));
assert!(memory_checker.check_memory().is_below());

let config = Config::from_json_value(serde_json::json!({
Expand All @@ -288,7 +288,7 @@ mod tests {
}
}))
.unwrap();
let memory_checker = MemoryStat::new().with_config(Arc::new(config));
let memory_checker = MemoryStat::new().init_checker(Arc::new(config));
assert!(memory_checker.check_memory().is_exceeded());
}

Expand Down

0 comments on commit 05b1317

Please sign in to comment.