Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrQueueEmpty = errors.New("queue: queue is empty") ErrJobTimeout = errors.New("queue: job execution timeout") )
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher 任务分发器
func (*Dispatcher) DispatchLater ¶
func (d *Dispatcher) DispatchLater(job *Job, delay time.Duration) error
DispatchLater 延迟分发任务
type Job ¶
type Job struct {
ID string `json:"id"`
Queue string `json:"queue"`
Payload map[string]interface{} `json:"payload"`
Attempts int `json:"attempts"`
MaxTries int `json:"max_tries"`
Timeout time.Duration `json:"timeout"`
CreatedAt time.Time `json:"created_at"`
}
Job 任务
type Queue ¶
type Queue interface {
// Push 推送任务到队列
Push(job *Job) error
// Pop 从队列获取任务
Pop(queue string) (*Job, error)
// Later 延迟推送任务
Later(job *Job, delay time.Duration) error
// Size 获取队列大小
Size(queue string) (int64, error)
// Clear 清空队列
Clear(queue string) error
}
Queue 队列接口
type SyncDriver ¶
type SyncDriver struct {
// contains filtered or unexported fields
}
SyncDriver 同步内存队列驱动
Click to show internal directories.
Click to hide internal directories.