Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
XAMPPRocky committed May 12, 2021
1 parent 52a58ec commit 320a75a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/extensions/filter_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ pub struct FilterManager {

/// ListenerManagerArgs contains arguments when invoking the LDS resource manager.
pub(crate) struct ListenerManagerArgs {
pub filter_registry: Arc<FilterRegistry>,
pub filter_chain_updates_tx: mpsc::Sender<Arc<FilterChain>>,
pub filter_registry: Arc<FilterRegistry>,
pub metrics_registry: Registry,
}

Expand All @@ -46,9 +46,9 @@ impl ListenerManagerArgs {
filter_chain_updates_tx: mpsc::Sender<Arc<FilterChain>>,
) -> ListenerManagerArgs {
ListenerManagerArgs {
metrics_registry,
filter_registry,
filter_chain_updates_tx,
filter_registry,
metrics_registry,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/extensions/filter_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ impl fmt::Display for Error {
}
}

impl Into<ValidationError> for Error {
fn into(self) -> ValidationError {
ValidationError::FilterInvalid(self)
impl From<Error> for ValidationError {
fn from(error: Error) -> Self {
Self::FilterInvalid(error)
}
}

Expand Down
21 changes: 14 additions & 7 deletions src/extensions/filters/local_rate_limit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@ impl RateLimitFilter {
while !refilled {
let remaining_tokens = available_tokens.load(Ordering::Relaxed);

refilled = available_tokens.compare_and_swap(
refilled = available_tokens.compare_exchange(
remaining_tokens,
max_tokens,
Ordering::Relaxed) == remaining_tokens;
Ordering::Relaxed,
Ordering::Relaxed,
).unwrap_or_else(|b| b) == remaining_tokens;
}
},
_ = &mut shutdown_rx => {
Expand Down Expand Up @@ -166,11 +168,16 @@ impl RateLimitFilter {
return None;
}

if self.available_tokens.compare_and_swap(
remaining_tokens,
remaining_tokens - 1,
Ordering::Relaxed,
) == remaining_tokens
if self
.available_tokens
.compare_exchange(
remaining_tokens,
remaining_tokens - 1,
Ordering::Relaxed,
Ordering::Relaxed,
)
.unwrap_or_else(|b| b)
== remaining_tokens
{
return Some(());
}
Expand Down
10 changes: 2 additions & 8 deletions src/proxy/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,8 @@ mod tests {
// since we don't know what the session ephemeral port is, we'll just
// search for the filter strings.
let result = endpoint.packet_rx.await.unwrap();
assert!(
result.contains(msg),
format!("'{}' not found in '{}'", msg, result)
);
assert!(
result.contains(":odr:"),
format!(":odr: not found in '{}'", result)
);
assert!(result.contains(msg), "'{}' not found in '{}'", msg, result);
assert!(result.contains(":odr:"), ":odr: not found in '{}'", result);
}

#[tokio::test]
Expand Down

0 comments on commit 320a75a

Please sign in to comment.