Documentation
¶
Index ¶
- Constants
- Variables
- type Failure
- type FairQueue
- func (f *FairQueue) Cap() int
- func (f *FairQueue) Close()
- func (f *FairQueue) Copy() []Task
- func (f *FairQueue) ForcePublish(t Task) error
- func (f *FairQueue) Free() int
- func (f *FairQueue) IsClosed() bool
- func (f *FairQueue) Len() int
- func (f *FairQueue) Pop() (Task, error)
- func (f *FairQueue) Publish(t Task) bool
- func (f *FairQueue) Resize(cap int) bool
- func (f *FairQueue) Save(_ func(Task))
- func (f *FairQueue) Subscribe() (chan Task, error)
- func (f *FairQueue) TryPop() (Task, bool)
- type Finalizer
- type NewQueue
- type Options
- type PollTask
- func (p *PollTask) Callback(id string, f Finalizer) error
- func (p *PollTask) ForEach(f func(string, Pollable) bool)
- func (p *PollTask) Get(id string) (Pollable, bool)
- func (p *PollTask) Kill(id string) error
- func (p *PollTask) Poll(f func(string, Pollable))
- func (p *PollTask) PollOne(id string) (bool, error)
- func (p *PollTask) Register(pb Pollable)
- func (p *PollTask) Remove(pb Pollable)
- type Pollable
- type Queue
- type RetryFunc
- type SimpleQueue
- func (s *SimpleQueue) Cap() int
- func (s *SimpleQueue) Close()
- func (s *SimpleQueue) Copy() []Task
- func (s *SimpleQueue) ForcePublish(t Task) error
- func (s *SimpleQueue) Free() int
- func (s *SimpleQueue) IsClosed() bool
- func (s *SimpleQueue) Len() int
- func (s *SimpleQueue) Pop() (Task, error)
- func (s *SimpleQueue) Publish(t Task) bool
- func (s *SimpleQueue) Resize(capSize int) bool
- func (s *SimpleQueue) Save(f func(Task))
- func (s *SimpleQueue) Subscribe() (chan Task, error)
- func (s *SimpleQueue) TryPop() (Task, bool)
- type Task
- type TaskEntry
- func (t *TaskEntry) Do() error
- func (t *TaskEntry) Error() error
- func (t *TaskEntry) ID() string
- func (t *TaskEntry) Interrupt()
- func (t *TaskEntry) IsDone() bool
- func (t *TaskEntry) IsReachLimits() bool
- func (t *TaskEntry) IsRunUntilSuccess() bool
- func (t *TaskEntry) OnDone(f ...Finalizer)
- func (t *TaskEntry) OnFail(f ...Failure)
- func (t *TaskEntry) SetTaskError(err error)
- func (t *TaskEntry) Stop()
- func (t *TaskEntry) String() string
- func (t *TaskEntry) TaskContext() *sync.Map
- func (t *TaskEntry) TaskError() error
- func (t *TaskEntry) Wait()
- type TaskFunc
- type TaskOptions
- func LockRequired() TaskOptions
- func WithContext(ctx context.Context) TaskOptions
- func WithFailLimits(limits int) TaskOptions
- func WithNoRetryFunc() TaskOptions
- func WithOnTaskDone(f Finalizer) TaskOptions
- func WithOnTaskFail(f Failure) TaskOptions
- func WithRetryFunc(retry RetryFunc) TaskOptions
- func WithRetryLimit(retry int) TaskOptions
- func WithRunUntilSuccess(RunUntilSuccess bool) TaskOptions
- func WithTaskID(id string) TaskOptions
Constants ¶
View Source
const (
DefaultRetryLimit = 5
)
View Source
const (
DefaultSqSize = 1024
)
Variables ¶
View Source
var ( ErrTaskStopped = fmt.Errorf("task is stopped") ErrRetryReachLimits = fmt.Errorf("retry reaches limits") ErrFailReachLimits = fmt.Errorf("fails reaches limits") )
View Source
var (
ErrPollableEventsNotExists = fmt.Errorf("the pollable event doesn't exist")
)
View Source
var (
ErrQueueClosed = fmt.Errorf("queue is closed")
)
Functions ¶
This section is empty.
Types ¶
type FairQueue ¶
func (*FairQueue) ForcePublish ¶
type Queue ¶
type Queue interface { IsClosed() bool Publish(Task) bool ForcePublish(Task) error Subscribe() (chan Task, error) Close() TryPop() (Task, bool) Pop() (Task, error) Resize(int) bool Cap() int Len() int Free() int Copy() []Task // Save() acts like Copy() // but it only allows to call once. Save(func(Task)) }
func NewFairQueue ¶
func NewSimpleQueue ¶
type RetryFunc ¶
func DefaultRetry ¶
func DefaultRetry() RetryFunc
type SimpleQueue ¶
type SimpleQueue struct {
// contains filtered or unexported fields
}
func (*SimpleQueue) Cap ¶
func (s *SimpleQueue) Cap() int
func (*SimpleQueue) Copy ¶
func (s *SimpleQueue) Copy() []Task
func (*SimpleQueue) ForcePublish ¶
func (s *SimpleQueue) ForcePublish(t Task) error
func (*SimpleQueue) Free ¶
func (s *SimpleQueue) Free() int
func (*SimpleQueue) IsClosed ¶
func (s *SimpleQueue) IsClosed() bool
func (*SimpleQueue) Len ¶
func (s *SimpleQueue) Len() int
func (*SimpleQueue) Pop ¶
func (s *SimpleQueue) Pop() (Task, error)
func (*SimpleQueue) Publish ¶
func (s *SimpleQueue) Publish(t Task) bool
func (*SimpleQueue) Resize ¶
func (s *SimpleQueue) Resize(capSize int) bool
func (*SimpleQueue) Save ¶
func (s *SimpleQueue) Save(f func(Task))
func (*SimpleQueue) Subscribe ¶
func (s *SimpleQueue) Subscribe() (chan Task, error)
func (*SimpleQueue) TryPop ¶
func (s *SimpleQueue) TryPop() (Task, bool)
type Task ¶
type Task interface { Do() error Error() error TaskError() error ID() string Stop() Interrupt() IsDone() bool // The action function when tasks is stop or interrputed. OnDone(...Finalizer) // The action function when tasks run fail. OnFail(...Failure) Wait() String() string IsRunUntilSuccess() bool IsReachLimits() bool SetTaskError(error) TaskContext() *sync.Map }
func NewTask ¶
func NewTask(task TaskFunc, opts ...TaskOptions) Task
type TaskEntry ¶
type TaskEntry struct {
// contains filtered or unexported fields
}
func (*TaskEntry) IsReachLimits ¶
func (*TaskEntry) IsRunUntilSuccess ¶
func (*TaskEntry) SetTaskError ¶
func (*TaskEntry) TaskContext ¶
type TaskOptions ¶
type TaskOptions func(*TaskEntry)
func LockRequired ¶
func LockRequired() TaskOptions
func WithContext ¶
func WithContext(ctx context.Context) TaskOptions
func WithFailLimits ¶
func WithFailLimits(limits int) TaskOptions
func WithNoRetryFunc ¶
func WithNoRetryFunc() TaskOptions
fail fast. which promises the task will run once.
func WithOnTaskDone ¶
func WithOnTaskDone(f Finalizer) TaskOptions
func WithOnTaskFail ¶ added in v1.0.1
func WithOnTaskFail(f Failure) TaskOptions
func WithRetryFunc ¶
func WithRetryFunc(retry RetryFunc) TaskOptions
func WithRetryLimit ¶
func WithRetryLimit(retry int) TaskOptions
when the custom RetryFunc is set, the retry limit will be ignored.
func WithRunUntilSuccess ¶
func WithRunUntilSuccess(RunUntilSuccess bool) TaskOptions
func WithTaskID ¶
func WithTaskID(id string) TaskOptions
Click to show internal directories.
Click to hide internal directories.