package clock
import "k8s.io/apimachinery/pkg/util/clock"
Index ¶
- type Clock
- type FakeClock
- func NewFakeClock(t time.Time) *FakeClock
- func (f *FakeClock) After(d time.Duration) <-chan time.Time
- func (f *FakeClock) HasWaiters() bool
- func (f *FakeClock) NewTicker(d time.Duration) Ticker
- func (f *FakeClock) NewTimer(d time.Duration) Timer
- func (f *FakeClock) SetTime(t time.Time)
- func (f *FakeClock) Sleep(d time.Duration)
- func (f *FakeClock) Step(d time.Duration)
- type FakePassiveClock
- func NewFakePassiveClock(t time.Time) *FakePassiveClock
- func (f *FakePassiveClock) Now() time.Time
- func (f *FakePassiveClock) SetTime(t time.Time)
- func (f *FakePassiveClock) Since(ts time.Time) time.Duration
- type IntervalClock
- func (*IntervalClock) After(d time.Duration) <-chan time.Time
- func (*IntervalClock) NewTicker(d time.Duration) Ticker
- func (*IntervalClock) NewTimer(d time.Duration) Timer
- func (i *IntervalClock) Now() time.Time
- func (i *IntervalClock) Since(ts time.Time) time.Duration
- func (*IntervalClock) Sleep(d time.Duration)
- type PassiveClock
- type RealClock
- func (RealClock) After(d time.Duration) <-chan time.Time
- func (RealClock) NewTicker(d time.Duration) Ticker
- func (RealClock) NewTimer(d time.Duration) Timer
- func (RealClock) Now() time.Time
- func (RealClock) Since(ts time.Time) time.Duration
- func (RealClock) Sleep(d time.Duration)
- type Ticker
- type Timer
Types ¶
type Clock ¶
type Clock interface { PassiveClock After(time.Duration) <-chan time.Time NewTimer(time.Duration) Timer Sleep(time.Duration) NewTicker(time.Duration) Ticker }
Clock allows for injecting fake or real clocks into code that needs to do arbitrary things based on time.
type FakeClock ¶
type FakeClock struct { FakePassiveClock // contains filtered or unexported fields }
FakeClock implements Clock, but returns an arbitrary time.
func NewFakeClock ¶
func (*FakeClock) After ¶
Fake version of time.After(d).
func (*FakeClock) HasWaiters ¶
Returns true if After has been called on f but not yet satisfied (so you can write race-free tests).
func (*FakeClock) NewTicker ¶
func (*FakeClock) NewTimer ¶
Fake version of time.NewTimer(d).
func (*FakeClock) SetTime ¶
Sets the time.
func (*FakeClock) Sleep ¶
func (*FakeClock) Step ¶
Move clock by Duration, notify anyone that's called After, Tick, or NewTimer
type FakePassiveClock ¶
type FakePassiveClock struct {
// contains filtered or unexported fields
}
FakePassiveClock implements PassiveClock, but returns an arbitrary time.
func NewFakePassiveClock ¶
func NewFakePassiveClock(t time.Time) *FakePassiveClock
func (*FakePassiveClock) Now ¶
func (f *FakePassiveClock) Now() time.Time
Now returns f's time.
func (*FakePassiveClock) SetTime ¶
func (f *FakePassiveClock) SetTime(t time.Time)
Sets the time.
func (*FakePassiveClock) Since ¶
func (f *FakePassiveClock) Since(ts time.Time) time.Duration
Since returns time since the time in f.
type IntervalClock ¶
IntervalClock implements Clock, but each invocation of Now steps the clock forward the specified duration
func (*IntervalClock) After ¶
func (*IntervalClock) After(d time.Duration) <-chan time.Time
Unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) NewTicker ¶
func (*IntervalClock) NewTicker(d time.Duration) Ticker
Unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) NewTimer ¶
func (*IntervalClock) NewTimer(d time.Duration) Timer
Unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) Now ¶
func (i *IntervalClock) Now() time.Time
Now returns i's time.
func (*IntervalClock) Since ¶
func (i *IntervalClock) Since(ts time.Time) time.Duration
Since returns time since the time in i.
func (*IntervalClock) Sleep ¶
func (*IntervalClock) Sleep(d time.Duration)
type PassiveClock ¶
PassiveClock allows for injecting fake or real clocks into code that needs to read the current time but does not support scheduling activity in the future.
type RealClock ¶
type RealClock struct{}
RealClock really calls time.Now()
func (RealClock) After ¶
Same as time.After(d).
func (RealClock) NewTicker ¶
func (RealClock) NewTimer ¶
func (RealClock) Now ¶
Now returns the current time.
func (RealClock) Since ¶
Since returns time since the specified timestamp.
func (RealClock) Sleep ¶
type Ticker ¶
type Timer ¶
Timer allows for injecting fake or real timers into code that needs to do arbitrary things based on time.
Source Files ¶
clock.go
- Version
- v0.17.15-rc.0
- Published
- Nov 5, 2020
- Platform
- js/wasm
- Imports
- 2 packages
- Last checked
- 3 hours ago –
Tools for package owners.