scheduler

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MIT Imports: 10 Imported by: 0

README

scheduler

config file
           \-> include config files
            -> jobs
                   \-> job name
                    -> cron expression
                    -> retry times
                    -> tasks
                            \-> task name
                             -> task type
                             -> args

Documentation

Index

Constants

View Source
const (
	IntervalJsonCodecFlag string = "_internal_json_codec"
	// IntervalXmlCodecFlag string = "_internal_xml_codec"
	IntervalYamlCodecFlag string = "_internal_yaml_codec"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Marshal(in interface{}) (out []byte, err error)
	Unmarshal(data []byte, v interface{}) error
}

type File

type File struct {
	Includes []string `json:"includes,omitempty" yaml:"includes,omitempty" validate:"dive,file"`
	Jobs     []Job    `json:"jobs" yaml:"jobs" validate:"required,dive,required"`
}

type Handler

type Handler interface {
	Help() (task *Task)
	NewBody(args map[string]interface{}) (body interface{}, err error)
	Validate(validate *validator.Validate, body interface{}) (err error)
	Handle(body interface{}) (cancel func() error, err error)
}

type InternalJsonCodec

type InternalJsonCodec struct{}

func (*InternalJsonCodec) Marshal

func (c *InternalJsonCodec) Marshal(in interface{}) (out []byte, err error)

func (*InternalJsonCodec) Unmarshal

func (c *InternalJsonCodec) Unmarshal(data []byte, v interface{}) error

type InternalYamlCodec

type InternalYamlCodec struct{}

NOTE: Not support XML InternalXmlCodec struct{}

func (*InternalYamlCodec) Marshal

func (c *InternalYamlCodec) Marshal(in interface{}) (out []byte, err error)

func (*InternalYamlCodec) Unmarshal

func (c *InternalYamlCodec) Unmarshal(data []byte, v interface{}) error

type Job

type Job struct {
	Name       string `json:"name" yaml:"name" validate:"required"`
	Cron       string `json:"cron" yaml:"cron" validate:"omitempty,cron"`
	RetryTimes int    `json:"retryTimes,omitempty" yaml:"retryTimes,omitempty" validate:"min=0"`
	Tasks      []Task `json:"tasks" yaml:"tasks" validate:"required,dive,required"`
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager() *Manager

func (*Manager) AddHandler

func (m *Manager) AddHandler(flag string, handler Handler) error

func (*Manager) AddJob

func (m *Manager) AddJob(jobs ...Job) error

func (*Manager) RemoveHandler

func (m *Manager) RemoveHandler(flag string)

func (*Manager) RemoveJob

func (m *Manager) RemoveJob(jobtag string)

func (*Manager) Start

func (m *Manager) Start()

func (*Manager) Stop added in v0.1.1

func (m *Manager) Stop() error

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser() *Parser

func (*Parser) Export

func (p *Parser) Export(path string, codec Codec) error

func (*Parser) GetJobs

func (p *Parser) GetJobs() []Job

func (*Parser) Load

func (p *Parser) Load(path string, codec Codec) error

func (*Parser) Reload

func (p *Parser) Reload(codec Codec) error

type Task

type Task struct {
	Name string                 `json:"name" yaml:"name" validate:"required"`
	Type string                 `json:"type" yaml:"type" validate:"required"`
	Args map[string]interface{} `json:"args,omitempty" yaml:"args,omitempty"`
}

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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