package clock
import "k8s.io/client-go/1.5/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) Now() time.Time
- func (f *FakeClock) SetTime(t time.Time)
- func (f *FakeClock) Since(ts time.Time) time.Duration
- func (f *FakeClock) Sleep(d time.Duration)
- func (f *FakeClock) Step(d time.Duration)
- func (f *FakeClock) Tick(d time.Duration) <-chan time.Time
- type IntervalClock
- func (*IntervalClock) After(d time.Duration) <-chan time.Time
- func (i *IntervalClock) Now() time.Time
- func (i *IntervalClock) Since(ts time.Time) time.Duration
- func (*IntervalClock) Sleep(d time.Duration)
- func (*IntervalClock) Tick(d time.Duration) <-chan time.Time
- type RealClock
Types ¶
type Clock ¶
type Clock interface { Now() time.Time Since(time.Time) time.Duration After(d time.Duration) <-chan time.Time Sleep(d time.Duration) Tick(d time.Duration) <-chan time.Time }
Clock allows for injecting fake or real clocks into code that needs to do arbitrary things based on time.
type FakeClock ¶
type FakeClock struct {
// 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) Now ¶
Now returns f's time.
func (*FakeClock) SetTime ¶
Sets the time.
func (*FakeClock) Since ¶
Since returns time since the time in f.
func (*FakeClock) Sleep ¶
func (*FakeClock) Step ¶
Move clock by Duration, notify anyone that's called After or Tick
func (*FakeClock) Tick ¶
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) 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)
func (*IntervalClock) Tick ¶
func (*IntervalClock) Tick(d time.Duration) <-chan time.Time
Unimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.
type RealClock ¶
type RealClock struct{}
RealClock really calls time.Now()
func (RealClock) After ¶
Same as time.After(d).
func (RealClock) Now ¶
Now returns the current time.
func (RealClock) Since ¶
Since returns time since the specified timestamp.
func (RealClock) Sleep ¶
func (RealClock) Tick ¶
Source Files ¶
clock.go
- Version
- v1.5.0
- Published
- Oct 23, 2016
- Platform
- js/wasm
- Imports
- 2 packages
- Last checked
- 57 seconds ago –
Tools for package owners.