utils

package
v1.0.0-rc.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2018 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTimer

func NewTimer(d, jitter time.Duration) *timer

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock provides an interface to implement method for getting current time.

type DefaultClock

type DefaultClock struct{}

DefaultClock is an implementation of Clock interface.

func (*DefaultClock) Now

func (t *DefaultClock) Now() time.Time

Now returns current time.

type DefaultRand

type DefaultRand struct{}

DefaultRand is an implementation of Rand interface.

func (*DefaultRand) Float64

func (r *DefaultRand) Float64() float64

Float64 returns, as a float64, a pseudo-random number in [0.0,1.0) from the default Source.

func (*DefaultRand) Int63n

func (r *DefaultRand) Int63n(n int64) int64

Int63n returns, as an int64, a non-negative pseudo-random number in [0,n) from the default Source.

func (*DefaultRand) Intn

func (r *DefaultRand) Intn(n int) int

Intn returns, as an int, a non-negative pseudo-random number in [0,n) from the default Source.

type MockClock

type MockClock struct {
	NowTime int64
}

MockClock is a struct to record current time.

func (*MockClock) Increment

func (c *MockClock) Increment(d int64) time.Time

Increment is a method to increase current time.

func (*MockClock) Now

func (c *MockClock) Now() time.Time

Now function returns NowTime value.

type MockRand

type MockRand struct {
	F64   float64
	Int   int
	Int64 int64
}

MockRand is an implementation of Rand interface.

func (*MockRand) Float64

func (r *MockRand) Float64() float64

Float64 returns value of F64.

func (*MockRand) Int63n

func (r *MockRand) Int63n(n int64) int64

Int63n returns value of Int64.

func (*MockRand) Intn

func (r *MockRand) Intn(n int) int

Intn returns value of Int.

type Rand

type Rand interface {
	Int63n(n int64) int64
	Intn(n int) int
	Float64() float64
}

Rand is an interface for a set of methods that return random value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL