Skip to content

Commit 25fee32

Browse files
committed
Review feedback
1 parent 9f8fbf9 commit 25fee32

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

relay-server/src/actors/project.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ impl Project {
537537

538538
/// If we know that a project is disabled, disallow metrics, too.
539539
fn metrics_allowed(&self) -> bool {
540-
if let Some(state) = self.get_valid_state() {
540+
if let Some(state) = self.valid_state() {
541541
state.check_disabled(&self.config).is_ok()
542542
} else {
543543
// Projects without state go back to the original state of allowing metrics.
@@ -551,7 +551,7 @@ impl Project {
551551

552552
/// Returns the current [`ExpiryState`] for this project.
553553
/// 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 {
555555
if let Some(state) = &self.state {
556556
match state.check_expiry(self.config.as_ref()) {
557557
Expiry::Updated => ExpiryState::Updated(state.clone()),
@@ -563,10 +563,11 @@ impl Project {
563563
}
564564
}
565565

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() {
570571
ExpiryState::Updated(state) => Some(state),
571572
ExpiryState::Stale(state) => Some(state),
572573
ExpiryState::Expired => None,
@@ -726,7 +727,7 @@ impl Project {
726727
/// request's scoping. Otherwise, this function returns partial scoping from the `request_meta`.
727728
/// See [`RequestMeta::get_partial_scoping`] for more information.
728729
fn scope_request(&self, meta: &RequestMeta) -> Scoping {
729-
match self.get_valid_state() {
730+
match self.valid_state() {
730731
Some(state) => state.scope_request(meta),
731732
None => meta.get_partial_scoping(),
732733
}
@@ -737,7 +738,7 @@ impl Project {
737738
mut envelope: Envelope,
738739
mut envelope_context: EnvelopeContext,
739740
) -> Result<CheckedEnvelope, DiscardReason> {
740-
let state = self.get_valid_state();
741+
let state = self.valid_state();
741742
if let Some(state) = state.as_deref() {
742743
if let Err(reason) = state.check_request(envelope.meta(), &self.config) {
743744
envelope_context.reject(Outcome::Invalid(reason));
@@ -820,10 +821,10 @@ mod tests {
820821

821822
if expiry > 0 {
822823
// With long expiry, should get a state
823-
assert!(project.get_valid_state().is_some());
824+
assert!(project.valid_state().is_some());
824825
} else {
825826
// 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());
827828
}
828829
}
829830
}

relay-server/src/actors/project_cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl Handler<GetCachedProjectState> for ProjectCache {
373373
) -> Self::Result {
374374
let project = self.get_or_create_project(message.project_key);
375375
project.get_or_fetch_state(false);
376-
project.get_valid_state()
376+
project.valid_state()
377377
}
378378
}
379379

@@ -571,7 +571,7 @@ impl Handler<FlushBuckets> for ProjectCache {
571571
let config = self.config.clone();
572572
let project_key = message.project_key();
573573
let project = self.get_or_create_project(project_key);
574-
let expiry_state = project.get_expiry_state();
574+
let expiry_state = project.expiry_state();
575575

576576
// Schedule an update to the project state if it is outdated, regardless of whether the
577577
// metrics can be forwarded or not. We never wait for this update.

0 commit comments

Comments
 (0)