Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy fixes #246

Merged
merged 2 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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