jobstores

package
v0.0.0-...-33208af Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DBName   string
	DBUser   string
	DBPasswd string
	DBHost   string
	DBPort   string
	TBName   string
}

type Job

type Job struct {
	ID            uint   `json:"id" gorm:"primarykey"`
	JobID         string `json:"job_id" gorm:"uniqueIndex;default:''"`
	FuncName      string `json:"func_name" gorm:"index;default:''"`
	FuncKwargs    string `json:"func_kwargs" gorm:"default:''"`
	SchedTimes    int    `json:"sched_times" gorm:"default:0"`
	IncrStep      int    `json:"incr_step" gorm:"default:3"`
	NextRunTime   int    `json:"next_run_time" gorm:"index;default:0"`
	MaxSchedTimes int    `json:"max_sched_times" gorm:"default:0"`
	CreatedAt     int    `json:"created_at" gorm:"not null"`
	UpdatedAt     int    `json:"updated_at" gorm:"default:0"`
	DeletedAt     int    `json:"deleted_at" gorm:"index;default:0"`
}

func (Job) String

func (j Job) String() string

func (Job) TableName

func (Job) TableName() string

type MySQLStore

type MySQLStore struct{}

func (MySQLStore) AddJob

func (s MySQLStore) AddJob(j Job) Job

func (MySQLStore) GetAllJobs

func (s MySQLStore) GetAllJobs() []Job

func (MySQLStore) GetDueJobs

func (s MySQLStore) GetDueJobs(t time.Time, cnt int) []Job

func (MySQLStore) GetWakeUpTime

func (s MySQLStore) GetWakeUpTime() (wakeUpTime int)

func (MySQLStore) LockJobs

func (s MySQLStore) LockJobs(jobs []Job, keepTime int) error

当前服务实例拉取任务下来上锁避免其他实例重复获取相同的任务 keepTime: 每个协程任务最大的运行时长

func (MySQLStore) LookupJob

func (s MySQLStore) LookupJob(ID string) Job

func (MySQLStore) RemoveAllJobs

func (s MySQLStore) RemoveAllJobs() error

func (MySQLStore) RemoveJob

func (s MySQLStore) RemoveJob(j Job) error

func (MySQLStore) Start

func (s MySQLStore) Start(config *Config)

func (MySQLStore) UpdateJob

func (s MySQLStore) UpdateJob(j Job) error

type StoreInterface

type StoreInterface interface {
	Start(*Config)
	LookupJob(ID string) Job
	GetDueJobs(t time.Time, cnt int) []Job
	GetWakeUpTime() (wakeUpTime int)
	AddJob(j Job) Job
	UpdateJob(j Job) error
	LockJobs(jobs []Job, keepTime int) error
	RemoveJob(j Job) error
	GetAllJobs() []Job
	RemoveAllJobs() error
}

Jump to

Keyboard shortcuts

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