Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Sleep ¶ added in v0.9.7
Sleep is like time.Sleep, but supports context.Context and more by short-circuiting on done. Returns true, unless short-circuited by done.
Example ¶
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/smartcontractkit/chainlink-common/pkg/timeutil"
)
func main() {
ctx := context.Background()
if !timeutil.Sleep(ctx.Done(), time.Second) {
log.Fatal("context done")
}
fmt.Printf("Slept for %s\n", time.Second)
}
Output: Slept for 1s
Types ¶
type JitterPct ¶
type JitterPct float64
JitterPct is a percent by which to scale a duration up or down. For example, 0.1 will result in +/- 10%.
Click to show internal directories.
Click to hide internal directories.