Documentation
¶
Index ¶
- Variables
- func IIF[T comparable](condition bool, trueValue, falseValue T) T
- func Ptr[T any](i T) *T
- func RandomBytes(n int) ([]byte, error)
- func RandomString(length uint8) string
- type KeyValue
- type TimeWheel
- func (tw *TimeWheel) AddTask(data any, delay time.Duration, callback TimeWheelTaskCallback) (taskID any, err error)
- func (tw *TimeWheel) AddTimer(taskID, data any, delay time.Duration, callback TimeWheelTaskCallback) error
- func (tw *TimeWheel) RemoveTask(taskID any) error
- func (tw *TimeWheel) ResetTask(taskID any, delay time.Duration) error
- func (tw *TimeWheel) Stop()
- type TimeWheelTaskCallback
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func IIF ¶ added in v0.5.2
func IIF[T comparable](condition bool, trueValue, falseValue T) T
IIF returns the trueValue if condition is true, otherwise returns falseValue.
func RandomBytes ¶ added in v0.4.3
RandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly.
func RandomString ¶ added in v0.4.3
RandomString returns a securely generated random string.
Notice: this is method copy from Echo
Types ¶
type KeyValue ¶ added in v0.2.6
type KeyValue struct { Key string `json:"key" yaml:"key"` Value string `json:"value" yaml:"value"` }
KeyValue is a key-value string pair. You can use expvar.KeyValue in advanced scenarios.
type TimeWheel ¶
type TimeWheel struct {
// contains filtered or unexported fields
}
A TimeWheel is a time wheel object to schedule tasks.
func NewTimeWheel ¶
NewTimeWheel create a new time wheel with the given interval and slot number.
once the time wheel is created, it will start to run tasks in a goroutine.
func (*TimeWheel) AddTask ¶
func (tw *TimeWheel) AddTask(data any, delay time.Duration, callback TimeWheelTaskCallback) (taskID any, err error)
AddTask add a task to the time wheel, return the task id
func (*TimeWheel) AddTimer ¶
func (tw *TimeWheel) AddTimer(taskID, data any, delay time.Duration, callback TimeWheelTaskCallback) error
AddTimer add a timer task, if task id exists, do reset operator
func (*TimeWheel) RemoveTask ¶
type TimeWheelTaskCallback ¶
TimeWheelTaskCallback defined the method to run task while timeout.
Directories
¶
Path | Synopsis |
---|---|
Package timeinterval is time range data structure ,many trade system has this.
|
Package timeinterval is time range data structure ,many trade system has this. |