schedule

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	//RegisterTypeCron  0 cron 表达式类型 例子 :"*/5 * * * *"
	RegisterTypeCron = iota
	//RegisterTypeTime  1 特定时间 例子: "2022-10-11 12:12" 精确到分
	RegisterTypeTime
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AppConf      dto.AppConf
	ScheduleConf dto.ScheduleConf
}

func (*Client) RegisterCorn

func (c *Client) RegisterCorn(input dto.ScheduleRegisterInput) error

RegisterCorn 表达式类型定时任务 例子 :"*/1 * * * *"

Example
conf := dto.AppConf{
	ServiceName: "test",
	Token:       "example",
}
spiderman, _ := spiderman2.NewSpiderman(conf)

schedule, _ := spiderman.Schedule(dto.ScheduleConf{
	BaseUri:     "http://127.0.0.1:8081",
	CallbackUri: "http://127.0.0.1:8080",
})
_ = schedule.RegisterCorn(dto.ScheduleRegisterInput{
	ScheduleId:     "test-talent",
	ScheduleName:   "ttttt",
	CallbackParams: nil,
	Value:          "*/1 * * * *",
})
Output:

func (*Client) RegisterCornTime

func (c *Client) RegisterCornTime(input dto.ScheduleRegisterInput) error

RegisterCornTime 特定时间定时任务

Example
conf := dto.AppConf{
	ServiceName: "test",
	Token:       "example",
}
spiderman, _ := spiderman2.NewSpiderman(conf)

schedule, _ := spiderman.Schedule(dto.ScheduleConf{
	BaseUri:     "http://127.0.0.1:8081",
	CallbackUri: "http://127.0.0.1:8080",
})
_ = schedule.RegisterCornTime(dto.ScheduleRegisterInput{
	ScheduleId:     "test-talent",
	ScheduleName:   "ttttt",
	CallbackParams: nil,
	Value:          "2022-01-01 12:01",
})
Output:

func (*Client) RegisterHandler

func (c *Client) RegisterHandler(r *gin.Engine, f gin.HandlerFunc, relativePath string) error

RegisterHandler 注册回调路由

func (*Client) UnRegister

func (c *Client) UnRegister(scheduleId string) error

UnRegister 取消定时任务

type ScheduleInterface

type ScheduleInterface interface {
	RegisterCorn(input dto.ScheduleRegisterInput) error                          //RegisterCorn 表达式类型定时任务 例子 :"*/1 * * * *"
	RegisterCornTime(input dto.ScheduleRegisterInput) error                      //RegisterCornTime 特定时间定时任务
	RegisterHandler(r *gin.Engine, f gin.HandlerFunc, relativePath string) error //RegisterHandler 注册回调路由
	UnRegister(scheduleId string) error                                          //UnRegister 取消定时任务
}

ScheduleInterface support pipelining using the RegisterCorn, RegisterCornTime, RegisterHandler and UnRegister methods

func NewClient

func NewClient(conf dto.AppConf, scheduleConf dto.ScheduleConf) ScheduleInterface

The NewClient interface is the primary interface for working with ScheduleInterface

Jump to

Keyboard shortcuts

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