queue

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(*Task) error

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func New

func New(storage *Store) *Queue

func (*Queue) Load

func (q *Queue) Load(handlers map[string]Handler) *Queue

Load 任务内容

func (*Queue) Pop

func (q *Queue) Pop(t Task)

func (*Queue) Push

func (q *Queue) Push(t *Task)

Push 任务

func (*Queue) Register

func (q *Queue) Register(tag string, h Handler)

Register 执行方法

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(store *driver.Storage) *Store

func (*Store) AddJob

func (e *Store) AddJob(t *Task) error

func (*Store) FetchJob

func (e *Store) FetchJob() []string

func (*Store) FetchTask

func (e *Store) FetchTask(name string) *Task

func (*Store) RemoveTask

func (e *Store) RemoveTask(t *Task) error

type StoreInterface

type StoreInterface interface {
	AddJob(string, string, string, float64) error
	FetchJob() []string                       //拉取任务队列
	FetchTask(string) string                  //获取单个执行任务。
	RemoveTask(name string, key string) error //删除任务
}

type Task

type Task struct {
	Key   string                 // system_name/job_id
	Delay int64                  // 延迟时间
	Cycle bool                   // 是否周期循环。
	Tag   string                 // Tag匹配Handler,无Tag的Task将不会被执行
	Args  map[string]interface{} // 任务参数
}

func UnmarshalJson

func UnmarshalJson(j string) (*Task, error)

func (*Task) MarshalJson

func (t *Task) MarshalJson() string

Directories

Path Synopsis
store

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL