mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
Hi San Diego (#85424)
* removed -staging/src/k8s.io/apimachinery/pkg/util/clock for golint failures * first few code comments are done * add correct comments for all packages
This commit is contained in:
parent
bf8c276019
commit
81d0007716
@ -324,7 +324,6 @@ staging/src/k8s.io/apimachinery/pkg/runtime/testing
|
|||||||
staging/src/k8s.io/apimachinery/pkg/selection
|
staging/src/k8s.io/apimachinery/pkg/selection
|
||||||
staging/src/k8s.io/apimachinery/pkg/test
|
staging/src/k8s.io/apimachinery/pkg/test
|
||||||
staging/src/k8s.io/apimachinery/pkg/types
|
staging/src/k8s.io/apimachinery/pkg/types
|
||||||
staging/src/k8s.io/apimachinery/pkg/util/clock
|
|
||||||
staging/src/k8s.io/apimachinery/pkg/util/errors
|
staging/src/k8s.io/apimachinery/pkg/util/errors
|
||||||
staging/src/k8s.io/apimachinery/pkg/util/framer
|
staging/src/k8s.io/apimachinery/pkg/util/framer
|
||||||
staging/src/k8s.io/apimachinery/pkg/util/httpstream
|
staging/src/k8s.io/apimachinery/pkg/util/httpstream
|
||||||
|
@ -52,23 +52,26 @@ func (RealClock) Since(ts time.Time) time.Duration {
|
|||||||
return time.Since(ts)
|
return time.Since(ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same as time.After(d).
|
// After is the same as time.After(d).
|
||||||
func (RealClock) After(d time.Duration) <-chan time.Time {
|
func (RealClock) After(d time.Duration) <-chan time.Time {
|
||||||
return time.After(d)
|
return time.After(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewTimer returns a new Timer.
|
||||||
func (RealClock) NewTimer(d time.Duration) Timer {
|
func (RealClock) NewTimer(d time.Duration) Timer {
|
||||||
return &realTimer{
|
return &realTimer{
|
||||||
timer: time.NewTimer(d),
|
timer: time.NewTimer(d),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewTicker returns a new Ticker.
|
||||||
func (RealClock) NewTicker(d time.Duration) Ticker {
|
func (RealClock) NewTicker(d time.Duration) Ticker {
|
||||||
return &realTicker{
|
return &realTicker{
|
||||||
ticker: time.NewTicker(d),
|
ticker: time.NewTicker(d),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sleep pauses the RealClock for duration d.
|
||||||
func (RealClock) Sleep(d time.Duration) {
|
func (RealClock) Sleep(d time.Duration) {
|
||||||
time.Sleep(d)
|
time.Sleep(d)
|
||||||
}
|
}
|
||||||
@ -94,12 +97,14 @@ type fakeClockWaiter struct {
|
|||||||
destChan chan time.Time
|
destChan chan time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewFakePassiveClock returns a new FakePassiveClock.
|
||||||
func NewFakePassiveClock(t time.Time) *FakePassiveClock {
|
func NewFakePassiveClock(t time.Time) *FakePassiveClock {
|
||||||
return &FakePassiveClock{
|
return &FakePassiveClock{
|
||||||
time: t,
|
time: t,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewFakeClock returns a new FakeClock
|
||||||
func NewFakeClock(t time.Time) *FakeClock {
|
func NewFakeClock(t time.Time) *FakeClock {
|
||||||
return &FakeClock{
|
return &FakeClock{
|
||||||
FakePassiveClock: *NewFakePassiveClock(t),
|
FakePassiveClock: *NewFakePassiveClock(t),
|
||||||
@ -120,14 +125,14 @@ func (f *FakePassiveClock) Since(ts time.Time) time.Duration {
|
|||||||
return f.time.Sub(ts)
|
return f.time.Sub(ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the time.
|
// SetTime sets the time on the FakePassiveClock.
|
||||||
func (f *FakePassiveClock) SetTime(t time.Time) {
|
func (f *FakePassiveClock) SetTime(t time.Time) {
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
defer f.lock.Unlock()
|
defer f.lock.Unlock()
|
||||||
f.time = t
|
f.time = t
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fake version of time.After(d).
|
// After is the Fake version of time.After(d).
|
||||||
func (f *FakeClock) After(d time.Duration) <-chan time.Time {
|
func (f *FakeClock) After(d time.Duration) <-chan time.Time {
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
defer f.lock.Unlock()
|
defer f.lock.Unlock()
|
||||||
@ -140,7 +145,7 @@ func (f *FakeClock) After(d time.Duration) <-chan time.Time {
|
|||||||
return ch
|
return ch
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fake version of time.NewTimer(d).
|
// NewTimer is the Fake version of time.NewTimer(d).
|
||||||
func (f *FakeClock) NewTimer(d time.Duration) Timer {
|
func (f *FakeClock) NewTimer(d time.Duration) Timer {
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
defer f.lock.Unlock()
|
defer f.lock.Unlock()
|
||||||
@ -157,6 +162,7 @@ func (f *FakeClock) NewTimer(d time.Duration) Timer {
|
|||||||
return timer
|
return timer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewTicker returns a new Ticker.
|
||||||
func (f *FakeClock) NewTicker(d time.Duration) Ticker {
|
func (f *FakeClock) NewTicker(d time.Duration) Ticker {
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
defer f.lock.Unlock()
|
defer f.lock.Unlock()
|
||||||
@ -174,14 +180,14 @@ func (f *FakeClock) NewTicker(d time.Duration) Ticker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move clock by Duration, notify anyone that's called After, Tick, or NewTimer
|
// Step moves clock by Duration, notifies anyone that's called After, Tick, or NewTimer
|
||||||
func (f *FakeClock) Step(d time.Duration) {
|
func (f *FakeClock) Step(d time.Duration) {
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
defer f.lock.Unlock()
|
defer f.lock.Unlock()
|
||||||
f.setTimeLocked(f.time.Add(d))
|
f.setTimeLocked(f.time.Add(d))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the time.
|
// SetTime sets the time on a FakeClock.
|
||||||
func (f *FakeClock) SetTime(t time.Time) {
|
func (f *FakeClock) SetTime(t time.Time) {
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
defer f.lock.Unlock()
|
defer f.lock.Unlock()
|
||||||
@ -219,7 +225,7 @@ func (f *FakeClock) setTimeLocked(t time.Time) {
|
|||||||
f.waiters = newWaiters
|
f.waiters = newWaiters
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if After has been called on f but not yet satisfied (so you can
|
// HasWaiters returns true if After has been called on f but not yet satisfied (so you can
|
||||||
// write race-free tests).
|
// write race-free tests).
|
||||||
func (f *FakeClock) HasWaiters() bool {
|
func (f *FakeClock) HasWaiters() bool {
|
||||||
f.lock.RLock()
|
f.lock.RLock()
|
||||||
@ -227,6 +233,7 @@ func (f *FakeClock) HasWaiters() bool {
|
|||||||
return len(f.waiters) > 0
|
return len(f.waiters) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sleep pauses the FakeClock for duration d.
|
||||||
func (f *FakeClock) Sleep(d time.Duration) {
|
func (f *FakeClock) Sleep(d time.Duration) {
|
||||||
f.Step(d)
|
f.Step(d)
|
||||||
}
|
}
|
||||||
@ -248,24 +255,25 @@ func (i *IntervalClock) Since(ts time.Time) time.Duration {
|
|||||||
return i.Time.Sub(ts)
|
return i.Time.Sub(ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unimplemented, will panic.
|
// After is currently unimplemented, will panic.
|
||||||
// TODO: make interval clock use FakeClock so this can be implemented.
|
// TODO: make interval clock use FakeClock so this can be implemented.
|
||||||
func (*IntervalClock) After(d time.Duration) <-chan time.Time {
|
func (*IntervalClock) After(d time.Duration) <-chan time.Time {
|
||||||
panic("IntervalClock doesn't implement After")
|
panic("IntervalClock doesn't implement After")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unimplemented, will panic.
|
// NewTimer is currently unimplemented, will panic.
|
||||||
// TODO: make interval clock use FakeClock so this can be implemented.
|
// TODO: make interval clock use FakeClock so this can be implemented.
|
||||||
func (*IntervalClock) NewTimer(d time.Duration) Timer {
|
func (*IntervalClock) NewTimer(d time.Duration) Timer {
|
||||||
panic("IntervalClock doesn't implement NewTimer")
|
panic("IntervalClock doesn't implement NewTimer")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unimplemented, will panic.
|
// NewTicker is currently unimplemented, will panic.
|
||||||
// TODO: make interval clock use FakeClock so this can be implemented.
|
// TODO: make interval clock use FakeClock so this can be implemented.
|
||||||
func (*IntervalClock) NewTicker(d time.Duration) Ticker {
|
func (*IntervalClock) NewTicker(d time.Duration) Ticker {
|
||||||
panic("IntervalClock doesn't implement NewTicker")
|
panic("IntervalClock doesn't implement NewTicker")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sleep is currently unimplemented; will panic.
|
||||||
func (*IntervalClock) Sleep(d time.Duration) {
|
func (*IntervalClock) Sleep(d time.Duration) {
|
||||||
panic("IntervalClock doesn't implement Sleep")
|
panic("IntervalClock doesn't implement Sleep")
|
||||||
}
|
}
|
||||||
@ -355,6 +363,7 @@ func (f *fakeTimer) Reset(d time.Duration) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ticker defines the Ticker interface
|
||||||
type Ticker interface {
|
type Ticker interface {
|
||||||
C() <-chan time.Time
|
C() <-chan time.Time
|
||||||
Stop()
|
Stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user