Documentation ¶
Index ¶
- Variables
- func ConvertFormat(s string) string
- func FormatTime(t time.Time, s string) string
- func GlobName(s string) string
- func GoSafe(fn func())
- func ParseDuration(s string) (time.Duration, error)
- func Recover(cleanups ...func())
- func RunSafe(fn func())
- func TryUnQuoted(v string) (string, bool)
- type Execute
- type JSONTime
- type TaskRunner
- type TimingWheel
- func (tw *TimingWheel) Drain(fn func(key, value interface{})) error
- func (tw *TimingWheel) MoveTimer(key interface{}, delay time.Duration) error
- func (tw *TimingWheel) RemoveTimer(key interface{}) error
- func (tw *TimingWheel) SetTimer(key, value interface{}, delay time.Duration) error
- func (tw *TimingWheel) Stop()
Constants ¶
This section is empty.
Variables ¶
var ( ErrClosed = errors.New("TimingWheel is closed already") ErrArgument = errors.New("incorrect task argument") )
var ErrUnknownTimeFormat = errors.New("unknown errors time format")
ErrUnknownTimeFormat defines the error type for unknown time format.
Functions ¶
func ConvertFormat ¶
ConvertFormat converts Java style layout to golang.
func FormatTime ¶
FormatTime format time with Java style layout.
func GoSafe ¶
func GoSafe(fn func())
GoSafe runs the given fn using another goroutine, recovers if fn panics.
func ParseDuration ¶
ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
Types ¶
type Execute ¶
type Execute func(key, value interface{})
Execute defines the method to execute the task.
type JSONTime ¶
JSONTime defines a time.Time that can be used in struct tag for JSON unmarshalling.
func (*JSONTime) UnmarshalJSON ¶
UnmarshalJSON unmarshals bytes to JSONTime.
type TaskRunner ¶
type TaskRunner struct {
// contains filtered or unexported fields
}
A TaskRunner is used to control the concurrency of goroutines.
func NewTaskRunner ¶
func NewTaskRunner(concurrency int) *TaskRunner
NewTaskRunner returns a TaskRunner.
func (*TaskRunner) Schedule ¶
func (rp *TaskRunner) Schedule(task func())
Schedule schedules a task to run under concurrency control.
type TimingWheel ¶
type TimingWheel struct {
// contains filtered or unexported fields
}
A TimingWheel is a timing wheel object to schedule tasks.
func NewTimingWheel ¶
NewTimingWheel returns a TimingWheel.
func (*TimingWheel) Drain ¶
func (tw *TimingWheel) Drain(fn func(key, value interface{})) error
Drain drains all items and executes them.
func (*TimingWheel) MoveTimer ¶
func (tw *TimingWheel) MoveTimer(key interface{}, delay time.Duration) error
MoveTimer moves the task with the given key to the given delay.
func (*TimingWheel) RemoveTimer ¶
func (tw *TimingWheel) RemoveTimer(key interface{}) error
RemoveTimer removes the task with the given key.
func (*TimingWheel) SetTimer ¶
func (tw *TimingWheel) SetTimer(key, value interface{}, delay time.Duration) error
SetTimer sets the task value with the given key to the delay.
func (*TimingWheel) Stop ¶
func (tw *TimingWheel) Stop()
Stop stops tw. No more actions after stopping a TimingWheel.