You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tokio::time::Instant has two important benefits over std::time::Instant (as well as the instant crate):
It supports mocking for tests via tokio::time::pause, etc. This allows a test to control how time advances, interacting well with the tokio timers.
It avoids panics. Especially on Amazon Linux/EKS, we have reports of time arithmetic causing runtime panics due to bugginess in the OS's time source and Rust's standard library.
Describe the solution you'd like
We should replace uses of std::time::Instant with tokio::time::Instant. We may also want to add a clippy configuration including:
disallowed-types = [
# Use parking_lot instead."std::sync::Mutex",
"std::sync::RwLock",
# Use tokio::time::Instant instead."std::time::Instant",
]
@clux I think it's a pretty trivial PR but, practically, it's probably blocked on ihrwein/backoff#53 -- while we can change the backoff clock, we can't really avoid panics due backoff's calls to duration_since, etc. I'll follow-up here when that PR shakes out a bit.
Would you like to work on this feature?
maybe
What problem are you trying to solve?
tokio::time::Instant
has two important benefits overstd::time::Instant
(as well as theinstant
crate):tokio::time::pause
, etc. This allows a test to control how time advances, interacting well with the tokio timers.Describe the solution you'd like
We should replace uses of
std::time::Instant
withtokio::time::Instant
. We may also want to add a clippy configuration including:See also:
tokio::time::Instant
inSystemClock
ihrwein/backoff#53Describe alternatives you've considered
Don't allow time mocking, wait for Rust std lib to solve panics in
Instant
.Documentation, Adoption, Migration Strategy
No response
Target crate for feature
kube-runtime
The text was updated successfully, but these errors were encountered: