les: implement new client pool (#19745)

This commit is contained in:
Felföldi Zsolt
2019-08-03 14:36:10 +02:00
committed by GitHub
parent 947f5f2b15
commit a7de796840
15 changed files with 1653 additions and 588 deletions

View File

@ -42,6 +42,12 @@ type Clock interface {
Now() AbsTime
Sleep(time.Duration)
After(time.Duration) <-chan time.Time
AfterFunc(d time.Duration, f func()) Event
}
// Event represents a cancellable event returned by AfterFunc
type Event interface {
Cancel() bool
}
// System implements Clock using the system clock.
@ -61,3 +67,16 @@ func (System) Sleep(d time.Duration) {
func (System) After(d time.Duration) <-chan time.Time {
return time.After(d)
}
// AfterFunc implements Clock.
func (System) AfterFunc(d time.Duration, f func()) Event {
return (*SystemEvent)(time.AfterFunc(d, f))
}
// SystemEvent implements Event using time.Timer.
type SystemEvent time.Timer
// Cancel implements Event.
func (e *SystemEvent) Cancel() bool {
return (*time.Timer)(e).Stop()
}