Documentation ¶
Index ¶
- Constants
- func IsIn(s string, arr []string) bool
- func ParseUTCTime(s string) (time.Time, error)
- func SetupConfigFile() error
- func ValidateGroups(groupID, totalGroupsNum uint) error
- type TimeInterval
- func (ti *TimeInterval) Duration() time.Duration
- func (ti *TimeInterval) End() time.Time
- func (ti *TimeInterval) EndString() string
- func (ti *TimeInterval) EndUnixMillis() int64
- func (ti *TimeInterval) EndUnixNano() int64
- func (ti *TimeInterval) MustRandWindow(window time.Duration) *TimeInterval
- func (ti *TimeInterval) Overlap(other *TimeInterval) bool
- func (ti *TimeInterval) RandWindow(window time.Duration) (*TimeInterval, error)
- func (ti *TimeInterval) Start() time.Time
- func (ti *TimeInterval) StartString() string
- func (ti *TimeInterval) StartUnixMillis() int64
- func (ti *TimeInterval) StartUnixNano() int64
Constants ¶
const ( // ErrEndBeforeStart is the error message for when a TimeInterval's end time // would be before its start. ErrEndBeforeStart = "end time before start time" )
Variables ¶
This section is empty.
Functions ¶
func ParseUTCTime ¶
ParseUTCTime parses a string-represented time of the format 2006-01-02T15:04:05Z07:00
func SetupConfigFile ¶
func SetupConfigFile() error
SetupConfigFile defines the settings for the configuration file support.
func ValidateGroups ¶
ValidateGroups checks validity of combination groupID and totalGroups
Types ¶
type TimeInterval ¶
type TimeInterval struct {
// contains filtered or unexported fields
}
TimeInterval represents an interval of time in UTC. That is, regardless of what timezone(s) are used for the beginning and end times, they will be converted to UTC and methods will return them as such.
func NewTimeInterval ¶
func NewTimeInterval(start, end time.Time) (*TimeInterval, error)
NewTimeInterval creates a new TimeInterval for a given start and end. If end is a time.Time before start, then an error is returned.
func (*TimeInterval) Duration ¶
func (ti *TimeInterval) Duration() time.Duration
Duration returns the time.Duration of the TimeInterval.
func (*TimeInterval) End ¶
func (ti *TimeInterval) End() time.Time
End returns the starting time in UTC.
func (*TimeInterval) EndString ¶
func (ti *TimeInterval) EndString() string
EndString formats the end of the TimeInterval according to RFC3339.
func (*TimeInterval) EndUnixMillis ¶
func (ti *TimeInterval) EndUnixMillis() int64
EndUnixMillis returns the end time as milliseconds.
func (*TimeInterval) EndUnixNano ¶
func (ti *TimeInterval) EndUnixNano() int64
EndUnixNano returns the end time as nanoseconds.
func (*TimeInterval) MustRandWindow ¶
func (ti *TimeInterval) MustRandWindow(window time.Duration) *TimeInterval
MustRandWindow is the form of RandWindow that cannot error; if it does error, it causes a panic.
func (*TimeInterval) Overlap ¶
func (ti *TimeInterval) Overlap(other *TimeInterval) bool
Overlap detects whether the given TimeInterval overlaps with this TimeInterval, assuming an inclusive start boundary and exclusive end boundary.
func (*TimeInterval) RandWindow ¶
func (ti *TimeInterval) RandWindow(window time.Duration) (*TimeInterval, error)
RandWindow creates a TimeInterval of duration `window` at a uniformly-random start time within the time period represented by this TimeInterval.
func (*TimeInterval) Start ¶
func (ti *TimeInterval) Start() time.Time
Start returns the starting time in UTC.
func (*TimeInterval) StartString ¶
func (ti *TimeInterval) StartString() string
StartString formats the start of the TimeInterval according to RFC3339.
func (*TimeInterval) StartUnixMillis ¶
func (ti *TimeInterval) StartUnixMillis() int64
StartUnixMillis returns the start time as milliseconds.
func (*TimeInterval) StartUnixNano ¶
func (ti *TimeInterval) StartUnixNano() int64
StartUnixNano returns the start time as nanoseconds.