schedule

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Cron schedule loop
	Cron *cacheSchedule
)
View Source
var (
	// Cron2 schedule loop
	Cron2 *cacheSchedule2
)
View Source
var (
	// ErrNoGetLog get real log from redis where no data
	ErrNoGetLog = errors.New("no read data from cache")
)
View Source
var (

	// ErrNoReadData define when read offset rather than len(bug), return this error
	ErrNoReadData = errors.New("no read data from cache")
)

Functions

func DealRPCErr

func DealRPCErr(err error) error

DealRPCErr change rpc error to err code

func DoStopConn

func DoStopConn(mode define.RunMode)

DoStopConn will cancel all running task and close grpc conn

func Init

func Init() error

Init start run already exists task from db

func Init2 added in v1.1.0

func Init2() error

Init2 start run already exists task from db

func InitWorker

func InitWorker()

InitWorker will set task running and save context.CancelFunc

func NewgRPCServer

func NewgRPCServer(mode define.RunMode) (*grpc.Server, error)

NewgRPCServer new gRPC server

func RecvEvent added in v1.1.0

func RecvEvent()

RecvEvent recv task event

func RegistryClient

func RegistryClient(version string, port int)

RegistryClient registry client to server

Types

type Auth

type Auth struct {
	SecretToken string
}

Auth check rpc request valid

func (*Auth) GetRequestMetadata

func (a *Auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata implement PerRPCCredentials interface

func (*Auth) RequireTransportSecurity

func (a *Auth) RequireTransportSecurity() bool

RequireTransportSecurity indicates whether the credentials requires transport security.

type EventData added in v1.1.0

type EventData struct {
	TaskID string    // task id
	TE     TaskEvent // task event: add change delete stop task
}

EventData sub data from redis 应用于调度节点集群,当添加任务、删除修改任务、终止任务时, 所有的集群调度节点都会接收到信息,然后进行相应的修改操作

type HeartbeatService

type HeartbeatService struct {
	Auth Auth
}

HeartbeatService implementation proto Heartbeat interface

func (*HeartbeatService) RegistryHost

func (hs *HeartbeatService) RegistryHost(ctx context.Context, req *pb.RegistryReq) (*pb.Empty, error)

RegistryHost client registry

func (*HeartbeatService) SendHb

func (hs *HeartbeatService) SendHb(ctx context.Context, hb *pb.HeartbeatReq) (*pb.Empty, error)

SendHb recv heatneat from client

type LogCache

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

LogCache otehr could read latest data from buf and do not clean it

func (*LogCache) Clean

func (l *LogCache) Clean()

Clean clean all data

func (*LogCache) Close

func (l *LogCache) Close()

Close will stop read data

func (*LogCache) Get

func (l *LogCache) Get() interface{}

Get task run host data

func (*LogCache) GetCode

func (l *LogCache) GetCode() int

GetCode return task return code

func (*LogCache) GetTaskStatus

func (l *LogCache) GetTaskStatus() define.TaskStatus

GetTaskStatus will be set task status is running or stop

func (*LogCache) ReadAll

func (l *LogCache) ReadAll() (p string)

ReadAll will Get All recv data

func (*LogCache) ReadOnly

func (l *LogCache) ReadOnly(p []byte, off int) (n int, err error)

ReadOnly Get data from buf

func (*LogCache) Save

func (l *LogCache) Save(data interface{})

Save save task run data

func (*LogCache) SetTaskStatus

func (l *LogCache) SetTaskStatus(status define.TaskStatus)

SetTaskStatus will be set task status is running or stop

func (*LogCache) Write

func (l *LogCache) Write(p []byte) (n int, err error)

Write recv byte and write buf

func (*LogCache) WriteString

func (l *LogCache) WriteString(p string) (n int, err error)

WriteString Write String to buf

func (*LogCache) WriteStringf

func (l *LogCache) WriteStringf(tmpl string, args ...interface{}) (n int, err error)

WriteStringf Write Tmpl string format to buf

type LogCacher

type LogCacher interface {
	// Read byte, but it not clean reader data
	// ReadOnly read data from buf
	// 从off后开始读,最多可以读取len(p)个字节,
	// - close为true,返回0,EOF
	// - off > len(l.buf),返回 noreaddata 这时读取方重新读取可以等待一会
	// - off+len(p) > len(l.buf),返回 p.buf.Len-off,nil
	// - off+len(p) < len(l.buf),返回 len(p), nil
	ReadOnly(p []byte, off int) (n int, err error)
	// Write byte buf
	Write(p []byte) (n int, err error)
	// Write byte buf,do not use it write recv task
	WriteString(p string) (n int, err error)
	// WriteStringf ,do not use it write recv task
	WriteStringf(tmpl string, args ...interface{}) (n int, err error)
	// Close will can not Read, and clean buf
	Clean()
	// Close will stop task
	Close()
	// ReadAll data from buf
	ReadAll() (p string)
	// GetCode return task return code
	GetCode() int
	// SetRunHost save task run host
	Save(interface{})
	// GetRunHost task run host addr
	Get() interface{}
	// SetTaskStatus set task status
	// wait running finish fail cancel
	SetTaskStatus(define.TaskStatus)
	GetTaskStatus() define.TaskStatus
}

LogCacher Write buf,ReadOnly from buf a stream write and read

func NewLogCache

func NewLogCache() LogCacher

NewLogCache return impl LogCache struct

type Next

type Next func() *define.Host

Next will return next run host if Next is nil,because not find valid host

func GetRoutePolicy

func GetRoutePolicy(hgid string, routepolicy define.RoutePolicy) Next

GetRoutePolicy return a type Next, it will return a host

type TaskEvent added in v1.1.0

type TaskEvent uint8

TaskEvent task event

const (
	// AddEvent recv add event
	AddEvent TaskEvent = iota + 1
	// ChangeEvent recv delete task
	ChangeEvent
	// DeleteEvent recv delete task
	DeleteEvent
	// RunEvent run a task
	RunEvent
	// KillEvent recv stop task
	KillEvent
)

type TaskService

type TaskService struct {
	Auth Auth
}

TaskService implementation proto task interface

func (*TaskService) RunTask

func (ts *TaskService) RunTask(req *pb.TaskReq, stream pb.Task_RunTaskServer) error

RunTask run task by rpc if start run,every output must be output by stream.Send return err must be err

Jump to

Keyboard shortcuts

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