Documentation ¶
Index ¶
- func Abs(a int) int
- func AbsForInt64(n int64) int64
- type Channel
- type ConcurrentBag
- type ConcurrentQueue
- type ConcurrentStack
- type Disposable
- type Fiber
- type GoroutineMulti
- func (g *GoroutineMulti) Dispose()
- func (g *GoroutineMulti) Enqueue(taskFunc any, params ...any)
- func (g *GoroutineMulti) EnqueueWithTask(task Task)
- func (g *GoroutineMulti) Schedule(firstInMs int64, taskFunc any, params ...any) (d Disposable)
- func (g *GoroutineMulti) ScheduleOnInterval(firstInMs int64, regularInMs int64, taskFunc any, params ...any) (d Disposable)
- func (g *GoroutineMulti) Start()
- func (g *GoroutineMulti) Stop()
- type GoroutineSingle
- func (g *GoroutineSingle) Dispose()
- func (g *GoroutineSingle) Enqueue(taskFunc any, params ...any)
- func (g *GoroutineSingle) EnqueueWithTask(task Task)
- func (g *GoroutineSingle) Schedule(firstInMs int64, taskFunc any, params ...any) (d Disposable)
- func (g *GoroutineSingle) ScheduleOnInterval(firstInMs int64, regularInMs int64, taskFunc any, params ...any) (d Disposable)
- func (g *GoroutineSingle) Start()
- func (g *GoroutineSingle) Stop()
- type IScheduler
- type Job
- func (j *Job) AfterExecuteTask() *Job
- func (j *Job) At(hh int, mm int, ss int) *Job
- func (j *Job) BeforeExecuteTask() *Job
- func (j *Job) Between(f time.Time, t time.Time) *Job
- func (j *Job) Days() *Job
- func (j *Job) Dispose()
- func (j *Job) Do(fun any, params ...any) Disposable
- func (j *Job) Hours() *Job
- func (j *Job) Milliseconds() *Job
- func (j *Job) Minutes() *Job
- func (j *Job) Seconds() *Job
- func (j *Job) Times(times int64) *Job
- type Subscriber
- type Task
- type UntilJob
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbsForInt64 ¶ added in v1.0.9
AbsForInt64 Returns the absolute value of a specified int64 number.
Types ¶
type Channel ¶ added in v1.0.10
Channel is a struct that has a member variable to store subscribers
func (*Channel) Count ¶ added in v1.0.10
Count returns a number that how many subscribers in the Channel.
func (*Channel) Subscribe ¶ added in v1.0.10
func (c *Channel) Subscribe(taskFunc any, params ...any) *Subscriber
Subscribe to register a receiver to receive the Channel's message
func (*Channel) Unsubscribe ¶ added in v1.0.10
Unsubscribe remove the subscriber from the channel
type ConcurrentBag ¶ added in v1.1.1
ConcurrentBag represents a thread-safe, unordered collection of element.
func NewConcurrentBag ¶ added in v1.1.1
func NewConcurrentBag() *ConcurrentBag
NewConcurrentBag new a ConcurrentStack instance
func (*ConcurrentBag) Add ¶ added in v1.1.1
func (cb *ConcurrentBag) Add(element any)
Add an element to the ConcurrentBag.
func (*ConcurrentBag) Clear ¶ added in v1.1.1
func (cb *ConcurrentBag) Clear()
Clear remove all element in the ConcurrentBag.
func (*ConcurrentBag) Len ¶ added in v1.1.1
func (cb *ConcurrentBag) Len() int
Len gets the number of elements contained in the ConcurrentBag.
func (*ConcurrentBag) ToArray ¶ added in v1.1.1
func (cb *ConcurrentBag) ToArray() (elements []any)
ToArray copies the ConcurrentBag elements to a new array.
func (*ConcurrentBag) TryTake ¶ added in v1.1.1
func (cb *ConcurrentBag) TryTake() (any, bool)
TryTake attempts to remove and return an element from the ConcurrentBag
type ConcurrentQueue ¶
ConcurrentQueue represents a thread-safe first in-first out (FIFO) collection.
func NewConcurrentQueue ¶
func NewConcurrentQueue() *ConcurrentQueue
NewConcurrentQueue new a ConcurrentQueue instance
func (*ConcurrentQueue) Clear ¶ added in v1.1.1
func (c *ConcurrentQueue) Clear()
Clear remove all element in the ConcurrentQueue.
func (*ConcurrentQueue) Enqueue ¶
func (c *ConcurrentQueue) Enqueue(element any)
Enqueue adds an object to the end of the ConcurrentQueue.
func (*ConcurrentQueue) Len ¶ added in v1.1.1
func (c *ConcurrentQueue) Len() int
Len gets the number of elements contained in the ConcurrentQueue.
func (*ConcurrentQueue) ToArray ¶ added in v1.1.1
func (c *ConcurrentQueue) ToArray() (elements []any)
ToArray copies the elements stored in the ConcurrentQueue to a new array.
func (*ConcurrentQueue) TryDequeue ¶
func (c *ConcurrentQueue) TryDequeue() (any, bool)
TryDequeue tries to remove and return the element at the beginning of the ConcurrentQueue.
func (*ConcurrentQueue) TryPeek ¶
func (c *ConcurrentQueue) TryPeek() (any, bool)
TryPeek tries to return an element from the beginning of the ConcurrentQueue without removing it.
type ConcurrentStack ¶ added in v1.1.1
ConcurrentStack represents a thread-safe last in-first out (LIFO) collection.
func NewConcurrentStack ¶ added in v1.1.1
func NewConcurrentStack() *ConcurrentStack
NewConcurrentStack new a ConcurrentStack instance
func (*ConcurrentStack) Clear ¶ added in v1.1.1
func (c *ConcurrentStack) Clear()
Clear remove all element in the ConcurrentStack.
func (*ConcurrentStack) Len ¶ added in v1.1.1
func (c *ConcurrentStack) Len() int
Len gets the number of elements contained in the ConcurrentStack.
func (*ConcurrentStack) Push ¶ added in v1.1.1
func (c *ConcurrentStack) Push(element any)
Push adds an object to the end of the ConcurrentStack.
func (*ConcurrentStack) ToArray ¶ added in v1.1.1
func (c *ConcurrentStack) ToArray() (elements []any)
ToArray copies the elements stored in the ConcurrentStack to a new array.
func (*ConcurrentStack) TryPeek ¶ added in v1.1.1
func (c *ConcurrentStack) TryPeek() (any, bool)
TryPeek tries to return an element from the beginning of the ConcurrentStack without removing it.
func (*ConcurrentStack) TryPop ¶ added in v1.1.1
func (c *ConcurrentStack) TryPop() (any, bool)
TryPop attempts to pop and return the object at the top of the
type Disposable ¶
type Disposable interface {
Dispose()
}
Disposable an interface just has only one function
type Fiber ¶
type Fiber interface { Start() Stop() Dispose() Enqueue(taskFunc any, params ...any) EnqueueWithTask(task Task) Schedule(firstInMs int64, taskFunc any, params ...any) (d Disposable) ScheduleOnInterval(firstInMs int64, regularInMs int64, taskFunc any, params ...any) (d Disposable) }
Fiber define some function
type GoroutineMulti ¶
type GoroutineMulti struct {
// contains filtered or unexported fields
}
GoroutineMulti a fiber backed by more goroutine. Each job is executed by a new goroutine.
func NewGoroutineMulti ¶
func NewGoroutineMulti() *GoroutineMulti
NewGoroutineMulti create a GoroutineMulti instance
func (*GoroutineMulti) Dispose ¶
func (g *GoroutineMulti) Dispose()
Dispose stop the fiber and release resource
func (*GoroutineMulti) Enqueue ¶
func (g *GoroutineMulti) Enqueue(taskFunc any, params ...any)
Enqueue use the fiber to execute a task
func (*GoroutineMulti) EnqueueWithTask ¶
func (g *GoroutineMulti) EnqueueWithTask(task Task)
EnqueueWithTask use the fiber to execute a task
func (*GoroutineMulti) Schedule ¶
func (g *GoroutineMulti) Schedule(firstInMs int64, taskFunc any, params ...any) (d Disposable)
Schedule execute the task once at the specified time that depends on parameter firstInMs.
func (*GoroutineMulti) ScheduleOnInterval ¶
func (g *GoroutineMulti) ScheduleOnInterval(firstInMs int64, regularInMs int64, taskFunc any, params ...any) (d Disposable)
ScheduleOnInterval execute the task once at the specified time that depends on parameters both firstInMs and regularInMs.
type GoroutineSingle ¶
type GoroutineSingle struct {
// contains filtered or unexported fields
}
GoroutineSingle a fiber backed by a dedicated goroutine. Every job is executed by a goroutine.
func NewGoroutineSingle ¶
func NewGoroutineSingle() *GoroutineSingle
NewGoroutineSingle create a GoroutineSingle instance
func (*GoroutineSingle) Dispose ¶
func (g *GoroutineSingle) Dispose()
Dispose stop the fiber and release resource
func (*GoroutineSingle) Enqueue ¶
func (g *GoroutineSingle) Enqueue(taskFunc any, params ...any)
Enqueue use the fiber to execute a task
func (*GoroutineSingle) EnqueueWithTask ¶
func (g *GoroutineSingle) EnqueueWithTask(task Task)
EnqueueWithTask enqueue the parameter task into the queue waiting for executing.
func (*GoroutineSingle) Schedule ¶
func (g *GoroutineSingle) Schedule(firstInMs int64, taskFunc any, params ...any) (d Disposable)
Schedule execute the task once at the specified time that depends on parameter firstInMs.
func (*GoroutineSingle) ScheduleOnInterval ¶
func (g *GoroutineSingle) ScheduleOnInterval(firstInMs int64, regularInMs int64, taskFunc any, params ...any) (d Disposable)
ScheduleOnInterval execute the task once at the specified time that depends on parameters both firstInMs and regularInMs.
type IScheduler ¶
type IScheduler interface { Schedule(firstInMs int64, taskFunc any, params ...any) (d Disposable) ScheduleOnInterval(firstInMs int64, regularInMs int64, taskFunc any, params ...any) (d Disposable) Enqueue(taskFunc any, params ...any) EnqueueWithTask(task Task) Remove(d Disposable) Dispose() }
IScheduler an interface that for GoroutineMulti and GoroutineSingle use.
type Job ¶
Job store some information for cron use.
func Every ¶
Every the job will execute every N everyUnit(ex atHour、atMinute、atSecond、millisecond etc..).
func EveryWednesday ¶
func EveryWednesday() *Job
EveryWednesday the job will execute every Wednesday
func (*Job) AfterExecuteTask ¶ added in v1.0.1
AfterExecuteTask waiting for the job execute finish then calculating the job next execution time just for delay model、every N second and every N millisecond If you want some job every N minute、hour or day do once and want to calculate next execution time by after the job executed. Please use interval unit that Seconds or Milliseconds
func (*Job) BeforeExecuteTask ¶ added in v1.0.1
BeforeExecuteTask to calculate next execution time immediately don't wait
func (*Job) Between ¶ added in v1.0.12
Between the job will be executed only between an assigned period (from f to f time HH:mm:ss.ff).
func (*Job) Milliseconds ¶ added in v1.0.9
Milliseconds a time interval of execution
type Subscriber ¶ added in v1.0.10
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber is a struct for register to a channel
func (*Subscriber) Unsubscribe ¶ added in v1.0.10
func (c *Subscriber) Unsubscribe()
Unsubscribe remove the subscriber from the channel
type Task ¶ added in v1.0.6
type Task struct {
// contains filtered or unexported fields
}
Task a struct