@@ -374,14 +374,14 @@ struct UpdateProjectState {
374
374
375
375
#[ derive( Debug , PartialEq , Eq , PartialOrd , Ord , Hash , Clone , Copy ) ]
376
376
struct QueueKey {
377
- root_key : ProjectKey ,
377
+ own_key : ProjectKey ,
378
378
sampling_key : ProjectKey ,
379
379
}
380
380
381
381
impl QueueKey {
382
- fn new ( key : ProjectKey , sampling_key : ProjectKey ) -> Self {
382
+ fn new ( own_key : ProjectKey , sampling_key : ProjectKey ) -> Self {
383
383
Self {
384
- root_key : key ,
384
+ own_key ,
385
385
sampling_key,
386
386
}
387
387
}
@@ -404,7 +404,7 @@ impl Queue {
404
404
405
405
/// Adds the value to the queue for the provided key.
406
406
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) ;
408
408
self . index . entry ( key. sampling_key ) . or_default ( ) . insert ( key) ;
409
409
self . buffer . entry ( key) . or_default ( ) . push ( value) ;
410
410
}
@@ -541,13 +541,15 @@ impl ProjectCacheBroker {
541
541
}
542
542
543
543
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 {
545
545
queue_key. sampling_key
546
546
} else {
547
- queue_key. root_key
547
+ queue_key. own_key
548
548
} ;
549
549
550
550
// 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.
551
553
self . projects
552
554
. get ( & partial_key)
553
555
// Make sure we have only cached and valid state.
@@ -561,7 +563,7 @@ impl ProjectCacheBroker {
561
563
. and_then ( |key| self . projects . get ( & key) )
562
564
. and_then ( |p| p. valid_state ( ) ) ;
563
565
564
- self . handle_processing ( state. clone ( ) , sampling_state, envelope, envelope_context)
566
+ self . handle_processing ( state. clone ( ) , sampling_state, envelope, envelope_context) ;
565
567
}
566
568
}
567
569
@@ -673,9 +675,9 @@ impl ProjectCacheBroker {
673
675
let ValidateEnvelope { envelope, context } = message;
674
676
675
677
// 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 ( ) ;
677
679
let project_state = self
678
- . get_or_create_project ( root_key )
680
+ . get_or_create_project ( own_key )
679
681
. get_cached_state ( envelope. meta ( ) . no_cache ( ) )
680
682
. filter ( |st| !st. invalid ( ) ) ;
681
683
@@ -695,7 +697,7 @@ impl ProjectCacheBroker {
695
697
}
696
698
}
697
699
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 ) ) ;
699
701
self . pending_envelopes . enqueue ( key, ( envelope, context) ) ;
700
702
}
701
703
0 commit comments