shedlock

package module
v0.0.0-...-ae7d717 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

go-schedule

go-schedule

db 模拟 shedlock-spring 实现作业调度。

CREATE TABLE shedlock
(
    name       VARCHAR(64),
    lock_until TIMESTAMP(3) NULL,
    locked_at  TIMESTAMP(3) NULL,
    locked_by  VARCHAR(255),
    PRIMARY KEY (name)
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalHostName

func LocalHostName() string

func NewScLockRedis

func NewScLockRedis(rdb *redis.Client)

Types

type Locker

type Locker interface {
	AddFun(name string, spec string, cmd func()) error
	AddJob(name string, spec string, job cron.Job) error
	AddSchedules(schedules []*Schedule) error
	DoLock(name string) bool
	Insert(name string) bool
	Find(name string) *Schedule
	Update(name string) bool
	Unlock(name string) bool

	Start()
	Stop()
}

type LockerDb

type LockerDb struct {
	LockTime int `json:"lock_time" 20 sec`
	// contains filtered or unexported fields
}

LockerDb

func NewLockerDb

func NewLockerDb(db *gorm.DB) *LockerDb

func NewLockerDbFor

func NewLockerDbFor(db *gorm.DB, lockTime int) *LockerDb

func NewLockerDbWithLockTime

func NewLockerDbWithLockTime(db *gorm.DB, lockFor int) *LockerDb

func (LockerDb) AddFun

func (l LockerDb) AddFun(name string, spec string, cmd func()) error

func (LockerDb) AddJob

func (l LockerDb) AddJob(name string, spec string, job cron.Job) error

func (LockerDb) AddSchedules

func (l LockerDb) AddSchedules(schedules []*Schedule) error

func (LockerDb) DoLock

func (l LockerDb) DoLock(name string) bool

func (LockerDb) Find

func (l LockerDb) Find(name string) *Schedule

func (LockerDb) Insert

func (l LockerDb) Insert(name string) bool

func (LockerDb) Start

func (l LockerDb) Start()

func (LockerDb) Stop

func (l LockerDb) Stop()

func (LockerDb) Unlock

func (l LockerDb) Unlock(name string) bool

func (LockerDb) Update

func (l LockerDb) Update(name string) bool

type QuartzJob

type QuartzJob interface {
	cron.Job
}

type Schedule

type Schedule struct {
	Name     string
	Spec     string
	Cmd      func()
	Job      cron.Job
	LockTime int `json:"lock_time" 20 sec`
}

type ShedLock

type ShedLock struct {
	Name      string    `gorm:"name"`
	LockUntil time.Time `gorm:"lock_until"`
	LockedAt  time.Time `gorm:"locked_at"`
	LockedBy  string    `gorm:"locked_by" hostname+name`
}

Jump to

Keyboard shortcuts

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