Skip to content

Commit

Permalink
Clean up lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Mar 5, 2024
1 parent 810fe71 commit 1b5ab8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions framework/instruments/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use opentelemetry_api::global::meter_with_version;
use opentelemetry_api::metrics::{Histogram, Unit};

#[allow(unused)]
pub type OperationDurationMetric = Histogram<f64>;

#[allow(unused)]
pub fn create_operation_duration_metric() -> OperationDurationMetric {
meter_with_version(
"wt.operation",
Expand Down
2 changes: 1 addition & 1 deletion framework/instruments_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn wind_tunnel_instrument(args: TokenStream, input: TokenStream) -> TokenStr
.collect::<syn::Result<Vec<Option<_>>>>()
.unwrap()
.into_iter()
.filter_map(|x| x)
.flatten()
.fold(
Punctuated::<Expr, syn::token::Comma>::new(),
|mut punct, arg| {
Expand Down
16 changes: 11 additions & 5 deletions framework/runner/src/shutdown.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::{borrow::BorrowMut, sync::Arc};

use parking_lot::Mutex;
use tokio::{
signal,
sync::broadcast::{Receiver, Sender},
};
use tokio::sync::Mutex;

#[derive(Debug, Clone)]
pub(crate) struct ShutdownHandle {
Expand Down Expand Up @@ -42,10 +42,15 @@ impl DelegatedShutdownListener {
/// Point in time check if the shutdown signal has been received. If this returns true then work
/// be stopped so that the scenario can shut down.
pub fn should_shutdown(&mut self) -> bool {
match self.receiver.lock().try_recv() {
Ok(_) => true,
Err(tokio::sync::broadcast::error::TryRecvError::Closed) => true,
// If the receiver is empty or lagged then we should not shutdown.
match self.receiver.try_lock() {
Ok(mut guard) => {
match guard.try_recv() {
Ok(_) => true,
Err(tokio::sync::broadcast::error::TryRecvError::Closed) => true,
// If the receiver is empty or lagged then we should not shutdown.
Err(_) => false,
}
}
Err(_) => false,
}
}
Expand All @@ -57,6 +62,7 @@ impl DelegatedShutdownListener {
self.receiver
.borrow_mut()
.lock()
.await
.recv()
.await
.expect("Failed to receive shutdown signal");
Expand Down

0 comments on commit 1b5ab8a

Please sign in to comment.