@@ -537,7 +537,7 @@ impl Project {
537
537
538
538
/// If we know that a project is disabled, disallow metrics, too.
539
539
fn metrics_allowed ( & self ) -> bool {
540
- if let Some ( state) = self . get_valid_state ( ) {
540
+ if let Some ( state) = self . valid_state ( ) {
541
541
state. check_disabled ( & self . config ) . is_ok ( )
542
542
} else {
543
543
// Projects without state go back to the original state of allowing metrics.
@@ -551,7 +551,7 @@ impl Project {
551
551
552
552
/// Returns the current [`ExpiryState`] for this project.
553
553
/// If the project state's [`Expiry`] is `Expired`, do not return it.
554
- pub fn get_expiry_state ( & self ) -> ExpiryState {
554
+ pub fn expiry_state ( & self ) -> ExpiryState {
555
555
if let Some ( state) = & self . state {
556
556
match state. check_expiry ( self . config . as_ref ( ) ) {
557
557
Expiry :: Updated => ExpiryState :: Updated ( state. clone ( ) ) ,
@@ -563,10 +563,11 @@ impl Project {
563
563
}
564
564
}
565
565
566
- /// Returns self.state if it is not expired.
567
- /// Convenience wrapper around `check_expiry`.
568
- pub fn get_valid_state ( & self ) -> Option < Arc < ProjectState > > {
569
- match self . get_expiry_state ( ) {
566
+ /// Returns the project state if it is not expired.
567
+ ///
568
+ /// Convenience wrapper around [`expiry_state`](Self::expiry_state).
569
+ pub fn valid_state ( & self ) -> Option < Arc < ProjectState > > {
570
+ match self . expiry_state ( ) {
570
571
ExpiryState :: Updated ( state) => Some ( state) ,
571
572
ExpiryState :: Stale ( state) => Some ( state) ,
572
573
ExpiryState :: Expired => None ,
@@ -726,7 +727,7 @@ impl Project {
726
727
/// request's scoping. Otherwise, this function returns partial scoping from the `request_meta`.
727
728
/// See [`RequestMeta::get_partial_scoping`] for more information.
728
729
fn scope_request ( & self , meta : & RequestMeta ) -> Scoping {
729
- match self . get_valid_state ( ) {
730
+ match self . valid_state ( ) {
730
731
Some ( state) => state. scope_request ( meta) ,
731
732
None => meta. get_partial_scoping ( ) ,
732
733
}
@@ -737,7 +738,7 @@ impl Project {
737
738
mut envelope : Envelope ,
738
739
mut envelope_context : EnvelopeContext ,
739
740
) -> Result < CheckedEnvelope , DiscardReason > {
740
- let state = self . get_valid_state ( ) ;
741
+ let state = self . valid_state ( ) ;
741
742
if let Some ( state) = state. as_deref ( ) {
742
743
if let Err ( reason) = state. check_request ( envelope. meta ( ) , & self . config ) {
743
744
envelope_context. reject ( Outcome :: Invalid ( reason) ) ;
@@ -820,10 +821,10 @@ mod tests {
820
821
821
822
if expiry > 0 {
822
823
// With long expiry, should get a state
823
- assert ! ( project. get_valid_state ( ) . is_some( ) ) ;
824
+ assert ! ( project. valid_state ( ) . is_some( ) ) ;
824
825
} else {
825
826
// With 0 expiry, project should expire immediately. No state can be set.
826
- assert ! ( project. get_valid_state ( ) . is_none( ) ) ;
827
+ assert ! ( project. valid_state ( ) . is_none( ) ) ;
827
828
}
828
829
}
829
830
}
0 commit comments