cron

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 28 Imported by: 2

Documentation

Index

Constants

View Source
const Type string = "cron"

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body interface {
	io.Reader
	Scan(obj interface{}) error
}

type Config

type Config struct {
	Status server.Status `json:"status"`
}

type Counter

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

Counter 任务执行次数

func (*Counter) Get

func (m *Counter) Get() int

Get 获取任务执行次数

func (*Counter) Increase

func (m *Counter) Increase()

Increase 累加执行次数

type Job

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

func (*Job) GetKey

func (t *Job) GetKey() string

func (*Job) GetService

func (t *Job) GetService() string

func (*Job) IsImmediately

func (t *Job) IsImmediately() bool

type Option

type Option func(*options)

Option 参数设置类型

func WithConfig

func WithConfig(config config.Config) Option

WithConfig 设置Config

func WithServiceName added in v0.1.8

func WithServiceName(serviceName string) Option

WithServiceName 设置服务名称

type Request

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

Request 处理任务请求

func NewRequest

func NewRequest(job *Job) (r *Request, err error)

NewRequest 构建任务请求

func (*Request) Body

func (m *Request) Body() []byte

func (*Request) CanProc added in v0.1.7

func (m *Request) CanProc() bool

func (*Request) Context

func (m *Request) Context() sctx.Context

func (*Request) GetHeader

func (m *Request) GetHeader() map[string]string

func (*Request) GetMethod

func (m *Request) GetMethod() string

GetMethod 方法名

func (*Request) GetName

func (m *Request) GetName() string

GetName 服务名

func (*Request) GetRemoteAddr

func (m *Request) GetRemoteAddr() string

func (*Request) GetService

func (m *Request) GetService() string

GetService 服务名

func (*Request) NextTime

func (m *Request) NextTime(t time.Time) time.Time

NextTime 下次执行时间

func (*Request) Params

func (m *Request) Params() map[string]string

func (*Request) WithContext

func (m *Request) WithContext(ctx sctx.Context) alloter.IRequest

type Response

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

Request 处理任务请求

func NewResponse

func NewResponse(job *Job) (r *Response, err error)

NewRequest 构建任务请求

func (*Response) Flush

func (r *Response) Flush() error

func (*Response) Header

func (r *Response) Header() xtypes.SMap

func (*Response) Size

func (r *Response) Size() int

func (*Response) Status

func (r *Response) Status() int

func (*Response) Write

func (r *Response) Write(data []byte) (n int, err error)

func (*Response) WriteHeader

func (r *Response) WriteHeader(code int)

func (*Response) WriteString

func (r *Response) WriteString(s string) (n int, err error)

Writes the string into the response body.

func (*Response) Written

func (r *Response) Written() bool

Returns true if the response body was already written.

type Round

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

Round 轮数信息

func (*Round) CanProc added in v0.1.7

func (m *Round) CanProc() bool

func (*Round) Current

func (m *Round) Current() int

Get 获取任务在几轮后执行

func (*Round) Reduce

func (m *Round) Reduce()

Reduce 减少任务等待轮数

func (*Round) Update

func (m *Round) Update(v int)

Update 更新任务下次执行的轮数

type Server

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

func New

func New(name string, opts ...Option) *Server

New 实例化

func (*Server) Attempt

func (e *Server) Attempt() bool

Attempt 判断是否可以启动

func (*Server) Config

func (e *Server) Config(cfg config.Config)

func (*Server) Endpoint added in v0.1.8

func (e *Server) Endpoint() *url.URL

func (*Server) Group

func (e *Server) Group(group string, middlewares ...middleware.Middleware) *server.RouterGroup

func (*Server) Handle

func (e *Server) Handle(path string, obj interface{})

func (*Server) Name

func (e *Server) Name() string

func (*Server) Options

func (e *Server) Options(opts ...Option)

Options 设置参数

func (*Server) ServiceName added in v0.1.8

func (s *Server) ServiceName() string

ServiceName 服务名称

func (*Server) Start

func (e *Server) Start(ctx context.Context) error

Start 开始

func (*Server) Stop

func (e *Server) Stop(ctx context.Context) error

Shutdown 停止

func (*Server) Type

func (e *Server) Type() string

func (*Server) Use

func (e *Server) Use(middlewares ...middleware.Middleware)

type Setting

type Setting struct {
	Config      Config              `json:"config" yaml:"config"`
	Middlewares []middleware.Config `json:"middlewares"  yaml:"middlewares"`
	Jobs        []*Job              `json:"jobs"  yaml:"jobs"`
}

Jump to

Keyboard shortcuts

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