timeutils

package
v0.0.0-...-e5281c0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2013 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EpochDay

func EpochDay(time time.Time) int64

Retuns the number of the day since epoch

func GetHit

func GetHit(now time.Time, key string, period time.Duration) string

This is a generic function that returns key composed of current time, key and period

func RoundedBucket

func RoundedBucket(t time.Time, p time.Duration) time.Time

Returns epoch seconds rounded to the given period e.g. minutes rate would return epoch seconds with seconds set to zero hourly rate would return epoch seconds with minutes and seconds set to zero

Types

type BackoffTimer

type BackoffTimer struct {
	Delay float64
	// contains filtered or unexported fields
}

func NewBackoffTimer

func NewBackoffTimer(min float64, max float64) *BackoffTimer

func (*BackoffTimer) Increase

func (bo *BackoffTimer) Increase()

func (*BackoffTimer) Reset

func (bo *BackoffTimer) Reset()

type FreezedTime

type FreezedTime struct {
	CurrentTime time.Time
}

This is manually controlled time we use in tests

func (*FreezedTime) UtcNow

func (t *FreezedTime) UtcNow() time.Time

type RealTime

type RealTime struct {
}

Real clock time, used in production

func (*RealTime) UtcNow

func (*RealTime) UtcNow() time.Time

type TimeProvider

type TimeProvider interface {
	UtcNow() time.Time
}

This is the interface we use to mock time in tests

Jump to

Keyboard shortcuts

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