forked from smartcontractkit/chainlink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaces.go
36 lines (29 loc) · 915 Bytes
/
interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package utils
import "time"
// Nower is an interface that fulfills the Now method,
// following the behavior of time.Now.
type Nower interface {
Now() time.Time
}
// Afterer is an interface that fulfills the After method,
// following the behavior of time.After.
type Afterer interface {
After(d time.Duration) <-chan time.Time
}
// AfterNower is an interface that fulfills the `After()` and `Now()`
// methods.
//go:generate mockery --name AfterNower --output ../internal/mocks/ --case=underscore
type AfterNower interface {
After(d time.Duration) <-chan time.Time
Now() time.Time
}
// Clock is a basic type for scheduling events in the application.
type Clock struct{}
// Now returns the current time.
func (Clock) Now() time.Time {
return time.Now()
}
// After returns the current time if the given duration has elapsed.
func (Clock) After(d time.Duration) <-chan time.Time {
return time.After(d)
}