Skip to content

Commit 2280962

Browse files
authored
upgrade to hashbrown 0.15.0 (kube-rs#1599)
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]>
1 parent 2c97edd commit 2280962

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ educe = { version = "0.6.0", default-features = false }
4646
either = "1.6.1"
4747
form_urlencoded = "1.2.0"
4848
futures = { version = "0.3.17", default-features = false }
49-
hashbrown = "0.14.0"
49+
hashbrown = "0.15.0"
5050
home = "0.5.4"
5151
http = "1.1.0"
5252
http-body = "1.0.0"

deny.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ allow = [
3131
# Pulled in via aws_lc_rs when using rustls-tls and aws-lc-rs features
3232
# https://openssl-library.org/source/license/index.html
3333
"OpenSSL",
34+
# Pulled in via hashbrown through its foldhash dependency
35+
"Zlib",
3436
]
3537

3638
exceptions = [
@@ -64,10 +66,6 @@ multiple-versions = "deny"
6466
[[bans.skip]]
6567
name = "rustls-native-certs"
6668

67-
[[bans.skip]]
68-
# blocked on us swapping out serde_yaml
69-
name = "hashbrown"
70-
7169
[[bans.skip]]
7270
# base64 did some annoying breaking changes
7371
name = "base64"

kube-runtime/src/scheduler.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Delays and deduplicates [`Stream`](futures::stream::Stream) items
22
33
use futures::{stream::Fuse, Stream, StreamExt};
4-
use hashbrown::{hash_map::Entry, HashMap};
4+
use hashbrown::{hash_map::RawEntryMut, HashMap};
55
use pin_project::pin_project;
66
use std::{
77
collections::HashSet,
@@ -78,24 +78,24 @@ impl<T: Hash + Eq + Clone, R> SchedulerProj<'_, T, R> {
7878
.run_at
7979
.checked_add(*self.debounce)
8080
.unwrap_or_else(far_future);
81-
match self.scheduled.entry(request.message) {
81+
match self.scheduled.raw_entry_mut().from_key(&request.message) {
8282
// If new request is supposed to be earlier than the current entry's scheduled
8383
// time (for eg: the new request is user triggered and the current entry is the
8484
// reconciler's usual retry), then give priority to the new request.
85-
Entry::Occupied(mut old_entry) if old_entry.get().run_at >= request.run_at => {
85+
RawEntryMut::Occupied(mut old_entry) if old_entry.get().run_at >= request.run_at => {
8686
// Old entry will run after the new request, so replace it..
8787
let entry = old_entry.get_mut();
8888
self.queue.reset_at(&entry.queue_key, next_time);
8989
entry.run_at = next_time;
90-
old_entry.replace_key();
90+
old_entry.insert_key(request.message);
9191
}
92-
Entry::Occupied(_old_entry) => {
92+
RawEntryMut::Occupied(_old_entry) => {
9393
// Old entry will run before the new request, so ignore the new request..
9494
}
95-
Entry::Vacant(entry) => {
95+
RawEntryMut::Vacant(entry) => {
9696
// No old entry, we're free to go!
97-
let message = entry.key().clone();
98-
entry.insert(ScheduledEntry {
97+
let message = request.message.clone();
98+
entry.insert(request.message, ScheduledEntry {
9999
run_at: next_time,
100100
queue_key: self.queue.insert_at(message, next_time),
101101
});

0 commit comments

Comments
 (0)