File: clock.go

package info (click to toggle)
golang-gopkg-retry.v1 0.0~git20161025.0.c09f6b8-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 132 kB
  • ctags: 100
  • sloc: makefile: 2
file content (23 lines) | stat: -rw-r--r-- 514 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package retry // import "gopkg.in/retry.v1"

import "time"

// Clock represents a virtual clock interface that
// can be replaced for testing.
type Clock interface {
	Now() time.Time
	After(time.Duration) <-chan time.Time
}

// WallClock exposes wall-clock time as returned by time.Now.
type wallClock struct{}

// Now implements Clock.Now.
func (wallClock) Now() time.Time {
	return time.Now()
}

// After implements Clock.After.
func (wallClock) After(d time.Duration) <-chan time.Time {
	return time.After(d)
}