taskq

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: MIT Imports: 10 Imported by: 0

README

taskq

timer task scheluder in golang. using database(cockroachdb) to store task info.

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

func Version added in v1.0.4

func Version() string

Types

type DATE

type DATE = easysql.DATE

type DATETIME

type DATETIME = easysql.DATETIME

type FLOAT64

type FLOAT64 = easysql.FLOAT64

type FnHandler added in v1.0.6

type FnHandler func(ITask) error

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@127.0.0.1:26257/dbname

func (*TASKQ) SetExecTimeout

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

func (*TASKQ) SetMaxGoroutine

func (t *TASKQ) SetMaxGoroutine(maxWorkers int)

func (*TASKQ) SetPollingInterval

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

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) SetTaskNextRuntime added in v1.0.6

func (t *TASKQ) SetTaskNextRuntime(taskname string, tm time.Time) error

func (*TASKQ) Start

func (t *TASKQ) Start() error

func (*TASKQ) Subscribe

func (t *TASKQ) Subscribe(tasknameprefix string, handler FnHandler)

type TaskCreateInfo

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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