Documentation ¶
Index ¶
- func Abs(a int) int
- func AbsForInt64(n int64) int64
- type Channel
- type ConcurrentQueue
- type Disposable
- type Fiber
- type GoroutineMulti
- func (g *GoroutineMulti) Dispose()
- func (g *GoroutineMulti) Enqueue(taskFun interface{}, params ...interface{})
- func (g *GoroutineMulti) EnqueueWithTask(task Task)
- func (g *GoroutineMulti) Schedule(firstInMs int64, taskFun interface{}, params ...interface{}) (d Disposable)
- func (g *GoroutineMulti) ScheduleOnInterval(firstInMs int64, regularInMs int64, taskFun interface{}, params ...interface{}) (d Disposable)
- func (g *GoroutineMulti) Start()
- func (g *GoroutineMulti) Stop()
- type GoroutineSingle
- func (g *GoroutineSingle) Dispose()
- func (g *GoroutineSingle) Enqueue(taskFun interface{}, params ...interface{})
- func (g *GoroutineSingle) EnqueueWithTask(task Task)
- func (g *GoroutineSingle) Schedule(firstInMs int64, taskFun interface{}, params ...interface{}) (d Disposable)
- func (g *GoroutineSingle) ScheduleOnInterval(firstInMs int64, regularInMs int64, taskFun interface{}, params ...interface{}) (d Disposable)
- func (g *GoroutineSingle) Start()
- func (g *GoroutineSingle) Stop()
- type IScheduler
- type Item
- 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 interface{}, params ...interface{}) 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 MemoryCache
- type PriorityQueue
- func (pq PriorityQueue) Len() int
- func (pq PriorityQueue) Less(i, j int) bool
- func (pq *PriorityQueue) Pop() interface{}
- func (pq *PriorityQueue) Push(x interface{})
- func (pq *PriorityQueue) PushItem(item *Item)
- func (pq PriorityQueue) Swap(i, j int)
- func (pq *PriorityQueue) TryDequeue(limit int64) (*Item, bool)
- func (pq *PriorityQueue) Update(item *Item)
- 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) Publish ¶ added in v1.0.10
func (c *Channel) Publish(msg ...interface{})
Publish a message to all subscribers
func (*Channel) Subscribe ¶ added in v1.0.10
func (c *Channel) Subscribe(taskFun interface{}, params ...interface{}) *Subscriber
Subscribe to register a receiver to receive the Channel's message
func (*Channel) Unsubscribe ¶ added in v1.0.10
func (c *Channel) Unsubscribe(subscriber interface{})
Unsubscribe remove the subscriber from the channel
type ConcurrentQueue ¶
type ConcurrentQueue struct {
// contains filtered or unexported fields
}
ConcurrentQueue A "thread" safe string to anything items.
func NewConcurrentQueue ¶
func NewConcurrentQueue() *ConcurrentQueue
NewConcurrentQueue ConcurrentQueue Constructors
func (ConcurrentQueue) Clean ¶ added in v1.1.0
func (c ConcurrentQueue) Clean()
Clean remove all element in the ConcurrentQueue.
func (ConcurrentQueue) Count ¶
func (c ConcurrentQueue) Count() int
Count Gets the number of elements contained in the ConcurrentQueue.
func (*ConcurrentQueue) Enqueue ¶
func (c *ConcurrentQueue) Enqueue(item interface{})
Enqueue Adds an object to the end of the ConcurrentQueue.
func (*ConcurrentQueue) TryDequeue ¶
func (c *ConcurrentQueue) TryDequeue() (interface{}, bool)
TryDequeue Tries to remove and return the interface{} at the beginning of the concurrent queue.
func (*ConcurrentQueue) TryPeek ¶
func (c *ConcurrentQueue) TryPeek() (interface{}, bool)
TryPeek Tries to return an interface{} from the beginning of the ConcurrentQueue without removing it.
type Disposable ¶
type Disposable interface {
Dispose()
}
Disposable an interface just has only one function
type Fiber ¶
type Fiber interface { Start() Stop() Dispose() Enqueue(taskFun interface{}, params ...interface{}) EnqueueWithTask(task Task) Schedule(firstInMs int64, taskFun interface{}, params ...interface{}) (d Disposable) ScheduleOnInterval(firstInMs int64, regularInMs int64, taskFun interface{}, params ...interface{}) (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(taskFun interface{}, params ...interface{})
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, taskFun interface{}, params ...interface{}) (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, taskFun interface{}, params ...interface{}) (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(taskFun interface{}, params ...interface{})
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, taskFun interface{}, params ...interface{}) (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, taskFun interface{}, params ...interface{}) (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, taskFun interface{}, params ...interface{}) (d Disposable) ScheduleOnInterval(firstInMs int64, regularInMs int64, taskFun interface{}, params ...interface{}) (d Disposable) Enqueue(taskFun interface{}, params ...interface{}) EnqueueWithTask(task Task) Remove(d Disposable) Dispose() }
IScheduler an interface that for GoroutineMulti and GoroutineSingle use.
type Job ¶
Job store some infomartion 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) Do ¶
func (j *Job) Do(fun interface{}, params ...interface{}) Disposable
Do some job needs to execute.
func (*Job) Milliseconds ¶ added in v1.0.9
Milliseconds a time interval of execution
type MemoryCache ¶ added in v1.1.0
type PriorityQueue ¶ added in v1.1.0
type PriorityQueue []*Item
A PriorityQueue implements heap.Interface and holds Items. ie. the 0th element is the lowest value
func NewPriorityQueue ¶ added in v1.1.0
func NewPriorityQueue(capacity int) *PriorityQueue
func (PriorityQueue) Len ¶ added in v1.1.0
func (pq PriorityQueue) Len() int
func (PriorityQueue) Less ¶ added in v1.1.0
func (pq PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Pop ¶ added in v1.1.0
func (pq *PriorityQueue) Pop() interface{}
func (*PriorityQueue) Push ¶ added in v1.1.0
func (pq *PriorityQueue) Push(x interface{})
func (*PriorityQueue) PushItem ¶ added in v1.1.0
func (pq *PriorityQueue) PushItem(item *Item)
func (PriorityQueue) Swap ¶ added in v1.1.0
func (pq PriorityQueue) Swap(i, j int)
func (*PriorityQueue) TryDequeue ¶ added in v1.1.0
func (pq *PriorityQueue) TryDequeue(limit int64) (*Item, bool)
TryDequeue
func (*PriorityQueue) Update ¶ added in v1.1.0
func (pq *PriorityQueue) Update(item *Item)
update modifies the priority of an Item in the queue.
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