Skip to content

Commit

Permalink
upgrade to hashbrown 0.15.0 (#1599)
Browse files Browse the repository at this point in the history
Hashbrown 0.15.0 has reworked the entry API which requires the use of a
raw entry builder to replace keys.

Signed-off-by: Robert Rose <[email protected]>
  • Loading branch information
rorosen authored Oct 11, 2024
1 parent 2c97edd commit 2280962
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ educe = { version = "0.6.0", default-features = false }
either = "1.6.1"
form_urlencoded = "1.2.0"
futures = { version = "0.3.17", default-features = false }
hashbrown = "0.14.0"
hashbrown = "0.15.0"
home = "0.5.4"
http = "1.1.0"
http-body = "1.0.0"
Expand Down
6 changes: 2 additions & 4 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ allow = [
# Pulled in via aws_lc_rs when using rustls-tls and aws-lc-rs features
# https://openssl-library.org/source/license/index.html
"OpenSSL",
# Pulled in via hashbrown through its foldhash dependency
"Zlib",
]

exceptions = [
Expand Down Expand Up @@ -64,10 +66,6 @@ multiple-versions = "deny"
[[bans.skip]]
name = "rustls-native-certs"

[[bans.skip]]
# blocked on us swapping out serde_yaml
name = "hashbrown"

[[bans.skip]]
# base64 did some annoying breaking changes
name = "base64"
Expand Down
16 changes: 8 additions & 8 deletions kube-runtime/src/scheduler.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Delays and deduplicates [`Stream`](futures::stream::Stream) items

use futures::{stream::Fuse, Stream, StreamExt};
use hashbrown::{hash_map::Entry, HashMap};
use hashbrown::{hash_map::RawEntryMut, HashMap};
use pin_project::pin_project;
use std::{
collections::HashSet,
Expand Down Expand Up @@ -78,24 +78,24 @@ impl<T: Hash + Eq + Clone, R> SchedulerProj<'_, T, R> {
.run_at
.checked_add(*self.debounce)
.unwrap_or_else(far_future);
match self.scheduled.entry(request.message) {
match self.scheduled.raw_entry_mut().from_key(&request.message) {
// If new request is supposed to be earlier than the current entry's scheduled
// time (for eg: the new request is user triggered and the current entry is the
// reconciler's usual retry), then give priority to the new request.
Entry::Occupied(mut old_entry) if old_entry.get().run_at >= request.run_at => {
RawEntryMut::Occupied(mut old_entry) if old_entry.get().run_at >= request.run_at => {
// Old entry will run after the new request, so replace it..
let entry = old_entry.get_mut();
self.queue.reset_at(&entry.queue_key, next_time);
entry.run_at = next_time;
old_entry.replace_key();
old_entry.insert_key(request.message);
}
Entry::Occupied(_old_entry) => {
RawEntryMut::Occupied(_old_entry) => {
// Old entry will run before the new request, so ignore the new request..
}
Entry::Vacant(entry) => {
RawEntryMut::Vacant(entry) => {
// No old entry, we're free to go!
let message = entry.key().clone();
entry.insert(ScheduledEntry {
let message = request.message.clone();
entry.insert(request.message, ScheduledEntry {
run_at: next_time,
queue_key: self.queue.insert_at(message, next_time),
});
Expand Down

0 comments on commit 2280962

Please sign in to comment.