fixed

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Del

func Del(id string)

func Exist

func Exist(ids []string) (notExist []string)

func NewFixedTask

func NewFixedTask(f *Fixed) scheduler.Task

func SetDB

func SetDB(d DB)

Types

type AddState

type AddState byte
const (
	OK AddState = iota
	InternalError
	ConflictErr
	DataErr
)

func Add

func Add(ctx context.Context, id string, cronTimeStr string, start scheduler.UnixTimeSecond) AddState

type CronTime

type CronTime struct {
	cron.SpecSchedule
	// json:"Location" 覆盖嵌套的 Location 域
	LocationStr string `json:"Location"`
	StartTime   scheduler.UnixTimeSecond
	RawString   string `json:"raw"`
}

func NewCronTimeFromBytes

func NewCronTimeFromBytes(j []byte) *CronTime

func NewCronTimeFromSpec

func NewCronTimeFromSpec(s *cron.SpecSchedule, start scheduler.UnixTimeSecond, rawString string) *CronTime

func (*CronTime) ToBytes

func (c *CronTime) ToBytes() []byte

type DB

type DB interface {
	// ConflictErr : 当id已经存在,但是cronTime不相同时,返回ConflictErr
	// InternalError : 其他因为DB等原因造成存储失败时,返回 InternalError
	// DataErr : 数据解析等数据相关的错误,返回DataErr
	// OK : 其余情况都应是OK,包括id存在且cronTime相同的情况也是OK
	//
	// opFlag: 只有首次添加id的数据时(包括Del(id)后的首次添加),才更新DB中opFlag的值
	Add(id string, cronTime []byte, opFlag string) AddState

	Exist(ids []string) (notExist []string)
	Del(id string)
	Get(id string) (cronTime []byte, opFlag string, ok bool)

	Visit(startId string) (items []struct {
		Id       string
		CronTime []byte
		OpFlag   string
	},
		nextId string)
}

type Fixed

type Fixed struct {
	TryCount  uint16                   `json:"try"`
	Id        string                   `json:"id"`
	TimePoint scheduler.UnixTimeSecond `json:"tp"`
	OpFlag    string                   `json:"op"`
}

func FromBytes

func FromBytes(b []byte) *Fixed

func (*Fixed) Run

func (f *Fixed) Run(ctx context.Context, schedulerTime scheduler.UnixTimeSecond)

func (*Fixed) ToBytes

func (f *Fixed) ToBytes() []byte

type VisitItem

type VisitItem struct {
	Id          string
	CronTimeStr string
	Start       scheduler.UnixTimeSecond
}

func Visit

func Visit(startId string) (items []VisitItem, nextId string)

Jump to

Keyboard shortcuts

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