Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
XAMPPRocky committed May 11, 2021
1 parent 5124953 commit 5e429a2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 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
7 changes: 5 additions & 2 deletions src/proxy/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,14 @@ mod tests {
let result = endpoint.packet_rx.await.unwrap();
assert!(
result.contains(msg),
format!("'{}' not found in '{}'", msg, result)
"'{}' not found in '{}'",
msg,
result
);
assert!(
result.contains(":odr:"),
format!(":odr: not found in '{}'", result)
":odr: not found in '{}'",
result
);
}

Expand Down

0 comments on commit 5e429a2

Please sign in to comment.