taskQ

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_TABLE_NAME = "task_queue_2021"
)

Variables

View Source
var DEFAULT_RECOVER func() = func() {
	if err := recover(); err != nil {
		log.Println(err)
	}
}

Functions

This section is empty.

Types

type DATE

type DATE = easysql.DATE

type DATETIME

type DATETIME = easysql.DATETIME

type FLOAT64

type FLOAT64 = easysql.FLOAT64

type INT64

type INT64 = easysql.INT64

type ITask

type ITask interface {
	GetTaskName() string
	GetContent() string
	SetContent(content string) error
	GetNextRuntime() time.Time
	GetLastRuntime() time.Time
	GetExecFailCount() int
	SetNextRuntime(datetime time.Time) error
	DeleteTask() error
}

type STRING

type STRING = easysql.STRING

type TASKID

type TASKID = string

type TASKQ

type TASKQ struct {
	Recover func()
	// contains filtered or unexported fields
}

func NewtaskQ

func NewtaskQ() *TASKQ

func (*TASKQ) Close

func (t *TASKQ) Close()

func (*TASKQ) CreateMultiTasksIfNotExist

func (t *TASKQ) CreateMultiTasksIfNotExist(taskList []TaskCreateInfo) error

func (*TASKQ) CreateTaskIfNotExist

func (t *TASKQ) CreateTaskIfNotExist(taskname string, nextruntime time.Time, content string) error

func (*TASKQ) DeleteTask

func (t *TASKQ) DeleteTask(taskname string) error

func (*TASKQ) SetDBURL

func (t *TASKQ) SetDBURL(dbURL string)

数据库连接字符串: postgresql://user:passwd@10.91.26.225:2625/dbname

func (*TASKQ) SetExecTimeout

func (t *TASKQ) SetExecTimeout(execTimeout time.Duration)

execTimeout: 任务执行多久未结束认为执行失败需重新调度

func (*TASKQ) SetMaxGoroutine

func (t *TASKQ) SetMaxGoroutine(maxWorkers int)

maxWorkers : 最多几个协程并发处理消息

func (*TASKQ) SetPollingInterval

func (t *TASKQ) SetPollingInterval(pollingInterval time.Duration)

pollingInterval: 多久轮询一次数据库看有没有任务要执行

func (*TASKQ) SetRecover

func (t *TASKQ) SetRecover(fn func())

func (*TASKQ) SetTableName

func (t *TASKQ) SetTableName(tablename string)

func (*TASKQ) SetTaskContent

func (t *TASKQ) SetTaskContent(taskname string, content string) error

func (*TASKQ) Start

func (t *TASKQ) Start() error

func (*TASKQ) Subscribe

func (t *TASKQ) Subscribe(tasknameprefix string, handler func(ITask) error)

type TaskCreateInfo

type TaskCreateInfo struct {
	TaskName    string
	Nextruntime time.Time
	Content     string
}

Jump to

Keyboard shortcuts

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