xcron

package
v0.5.21 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeregisterServer

func DeregisterServer(name string)

Deregister 清理配置适配器

func RegisterServer

func RegisterServer(resolver ServerResover)

Register 注册配置文件适配器

Types

type Config

type Config struct {
	Addr   string        `json:"addr"`
	Status engine.Status `json:"status"`
	Proto  string        `json:"proto"`
}

type Job

type Job struct {
	Cron        string            `json:"cron"`
	Service     string            `json:"service"`
	Disable     bool              `json:"disable"`
	Immediately bool              `json:"immediately"`
	Monopoly    bool              `json:"monopoly"`
	WithSeconds bool              `json:"with_seconds"`
	Meta        metadata.Metadata `json:"meta,omitempty"`

	DlockKey string `json:"-"`
	// contains filtered or unexported fields
}

func (*Job) CalcExpireSeconds added in v0.4.0

func (m *Job) CalcExpireSeconds() int

func (*Job) GetKey

func (t *Job) GetKey() string

func (*Job) GetLockData added in v0.4.0

func (t *Job) GetLockData() string

服务地址

func (*Job) GetService

func (t *Job) GetService() string

服务地址

func (*Job) Init

func (m *Job) Init() (err error)

func (*Job) IsImmediately

func (t *Job) IsImmediately() bool

是否立即执行

func (*Job) IsMonopoly

func (t *Job) IsMonopoly() bool

是否独占

func (*Job) NextTime

func (m *Job) NextTime(t time.Time) (nextTime time.Time)

NextTime 下次执行时间

type Server

type Server interface {
	GetProto() string
	GetAddr() string
	Serve(ctx context.Context) (err error)
	Stop(ctx context.Context) error
	AddJob(jobs ...*Job) (keys []string, err error)
	RemoveJob(key ...string)
}

func NewServer

func NewServer(proto string,
	router *engine.RouterGroup,
	cfg config.Config,
	opts ...engine.Option) (Server, error)

NewServer 根据适配器名称及参数返回配置处理器

type ServerResover

type ServerResover interface {
	Name() string
	Resolve(name string,
		router *engine.RouterGroup,
		cfg config.Config,
		opts ...engine.Option) (Server, error)
}

ServerResover 定义配置文件转换方法

Jump to

Keyboard shortcuts

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