Skip to content

Commit 381c893

Browse files
committed
review comments
1 parent bcac670 commit 381c893

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

relay-server/src/actors/project_cache.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,14 @@ struct UpdateProjectState {
374374

375375
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
376376
struct QueueKey {
377-
root_key: ProjectKey,
377+
own_key: ProjectKey,
378378
sampling_key: ProjectKey,
379379
}
380380

381381
impl QueueKey {
382-
fn new(key: ProjectKey, sampling_key: ProjectKey) -> Self {
382+
fn new(own_key: ProjectKey, sampling_key: ProjectKey) -> Self {
383383
Self {
384-
root_key: key,
384+
own_key,
385385
sampling_key,
386386
}
387387
}
@@ -404,7 +404,7 @@ impl Queue {
404404

405405
/// Adds the value to the queue for the provided key.
406406
pub fn enqueue(&mut self, key: QueueKey, value: (Box<Envelope>, EnvelopeContext)) {
407-
self.index.entry(key.root_key).or_default().insert(key);
407+
self.index.entry(key.own_key).or_default().insert(key);
408408
self.index.entry(key.sampling_key).or_default().insert(key);
409409
self.buffer.entry(key).or_default().push(value);
410410
}
@@ -541,13 +541,15 @@ impl ProjectCacheBroker {
541541
}
542542

543543
let envelopes = self.pending_envelopes.dequeue(&project_key, |queue_key| {
544-
let partial_key = if queue_key.root_key == project_key {
544+
let partial_key = if queue_key.own_key == project_key {
545545
queue_key.sampling_key
546546
} else {
547-
queue_key.root_key
547+
queue_key.own_key
548548
};
549549

550550
// We return false if project is not cached or its state is invalid, true otherwise.
551+
// We only have to check `partial_key`, because we already know that the `project_key`s `state`
552+
// is valid and loaded.
551553
self.projects
552554
.get(&partial_key)
553555
// Make sure we have only cached and valid state.
@@ -561,7 +563,7 @@ impl ProjectCacheBroker {
561563
.and_then(|key| self.projects.get(&key))
562564
.and_then(|p| p.valid_state());
563565

564-
self.handle_processing(state.clone(), sampling_state, envelope, envelope_context)
566+
self.handle_processing(state.clone(), sampling_state, envelope, envelope_context);
565567
}
566568
}
567569

@@ -673,9 +675,9 @@ impl ProjectCacheBroker {
673675
let ValidateEnvelope { envelope, context } = message;
674676

675677
// Fetch the project state for our key and make sure it's not invalid.
676-
let root_key = envelope.meta().public_key();
678+
let own_key = envelope.meta().public_key();
677679
let project_state = self
678-
.get_or_create_project(root_key)
680+
.get_or_create_project(own_key)
679681
.get_cached_state(envelope.meta().no_cache())
680682
.filter(|st| !st.invalid());
681683

@@ -695,7 +697,7 @@ impl ProjectCacheBroker {
695697
}
696698
}
697699

698-
let key = QueueKey::new(root_key, sampling_key.unwrap_or(root_key));
700+
let key = QueueKey::new(own_key, sampling_key.unwrap_or(own_key));
699701
self.pending_envelopes.enqueue(key, (envelope, context));
700702
}
701703

0 commit comments

Comments
 (0)