merge #5512 again after reverting due to incorrect rebase (#5520)

* setup workspace global lints to prevent needless panics

* removed sources of panic in nym-crypto, nym-node and nym-api

* adjusted test code
This commit is contained in:
Jędrzej Stuczyński
2025-02-26 10:52:09 +00:00
committed by GitHub
parent 69b2448500
commit 65175fee09
40 changed files with 181 additions and 69 deletions
+3
View File
@@ -45,6 +45,9 @@ impl MetricsAggregator {
self.event_sender.clone()
}
// we must panic here to terminate as soon as possible, because the underlying code
// has to be resolved as it implies some serious logic bugs
#[allow(clippy::panic)]
pub fn register_handler<H>(&mut self, handler: H, update_interval: impl Into<Option<Duration>>)
where
H: MetricsHandler,
@@ -226,6 +226,8 @@ impl OnUpdateMetricsHandler for PrometheusGlobalNodeMetricsRegistryUpdater {
impl MetricsHandler for PrometheusGlobalNodeMetricsRegistryUpdater {
type Events = GlobalPrometheusData;
// SAFETY: `PrometheusNodeMetricsRegistryUpdater` doesn't have any associated events
#[allow(clippy::panic)]
async fn handle_event(&mut self, _event: Self::Events) {
panic!("this should have never been called! MetricsHandler has been incorrectly called on PrometheusNodeMetricsRegistryUpdater")
}
@@ -62,6 +62,8 @@ impl OnUpdateMetricsHandler for LegacyMixingStatsUpdater {
impl MetricsHandler for LegacyMixingStatsUpdater {
type Events = LegacyMixingData;
// SAFETY: `LegacyMixingStatsUpdater` doesn't have any associated events
#[allow(clippy::panic)]
async fn handle_event(&mut self, _event: Self::Events) {
panic!("this should have never been called! MetricsHandler has been incorrectly called on LegacyMixingStatsUpdater")
}
@@ -101,6 +101,8 @@ impl OnUpdateMetricsHandler for MixnetMetricsCleaner {
impl MetricsHandler for MixnetMetricsCleaner {
type Events = StaleMixnetMetrics;
// SAFETY: `MixnetMetricsCleaner` doesn't have any associated events
#[allow(clippy::panic)]
async fn handle_event(&mut self, _event: Self::Events) {
panic!("this should have never been called! MetricsHandler has been incorrectly called on MixnetMetricsCleaner")
}
@@ -54,6 +54,8 @@ impl OnUpdateMetricsHandler for PendingEgressPacketsUpdater {
impl MetricsHandler for PendingEgressPacketsUpdater {
type Events = PendingEgressPackets;
// SAFETY: `PendingEgressPacketsUpdater` doesn't have any associated events
#[allow(clippy::panic)]
async fn handle_event(&mut self, _event: Self::Events) {
panic!("this should have never been called! MetricsHandler has been incorrectly called on PendingEgressPacketsUpdater")
}