scheduler

package
v0.0.0-...-730ab85 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotExecuted = iota
	Executed
	Fail
	Finish
)
View Source
const (
	HandlerPrefix = "/sapi/scheduler/handler"
)
View Source
const (
	JobPrefix = "/sapi/scheduler/job"
)
View Source
const (
	RAND = iota
)
View Source
const (
	RegistryPrefix = "/sapi/scheduler/client"
)
View Source
const (
	WorkPrefix = "/sapi/scheduler/work"
)

Variables

This section is empty.

Functions

func RandSelector

func RandSelector(clients []string) (string, error)

func SelectClient

func SelectClient(scheduler int, clients []string) (string, error)

Types

type Client

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

func NewClient

func NewClient(client *etcdv3.Client) *Client

func (*Client) AddHandler

func (c *Client) AddHandler(handler Handler)

func (*Client) Bootstrap

func (c *Client) Bootstrap() error

func (*Client) Stop

func (c *Client) Stop()

type ClientInfo

type ClientInfo struct {
	ID     string
	Enable bool
}

type Handler

type Handler interface {
	GetNme() string
	Run(job *Job) error
}

type HandlerInfo

type HandlerInfo struct {
	Name    string
	Clients []string
}

type Handlers

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

func (*Handlers) DelClient

func (h *Handlers) DelClient(clientId string) error

监听到client掉线后删除handler里面的客户端

func (*Handlers) FindClients

func (h *Handlers) FindClients(name string) ([]string, error)

func (*Handlers) ListHandlers

func (h *Handlers) ListHandlers() ([]string, error)

func (*Handlers) PutHandler

func (h *Handlers) PutHandler(clientId, name string) error

type Job

type Job struct {
	ID          string
	Name        string
	Remark      string
	Cron        string
	RunMode     int
	ExecMode    int
	HandlerName string
	Scheduler   int
	ChildJobId  string
	Timeout     int64
	RetryNumber int
	UserName    string
	Email       string
	Param       string
	Status      int //是否开启
	// contains filtered or unexported fields
}

func (*Job) Run

func (j *Job) Run()

func (*Job) SetHandlers

func (j *Job) SetHandlers(handlers *Handlers)

func (*Job) SetWorks

func (j *Job) SetWorks(works *Works)

type Jobs

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

func (*Jobs) AddJob

func (j *Jobs) AddJob(job *Job) error

func (*Jobs) CountJob

func (j *Jobs) CountJob() (int64, error)

func (*Jobs) GetFirstJobKey

func (j *Jobs) GetFirstJobKey() (string, error)

func (*Jobs) GetJob

func (j *Jobs) GetJob(id string) (*Job, error)

func (*Jobs) ListJob

func (j *Jobs) ListJob() ([]*Job, error)

func (*Jobs) PageJob

func (j *Jobs) PageJob(firstKey string, limit int64) ([]*Job, error)

func (*Jobs) RemoveJob

func (j *Jobs) RemoveJob(id string) error

func (*Jobs) Watch

func (j *Jobs) Watch() (*etcdv3.Watcher, error)

type Registry

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

func (*Registry) Deregister

func (r *Registry) Deregister(id string) error

func (*Registry) GetClient

func (r *Registry) GetClient(id string) (*ClientInfo, error)

func (*Registry) ListClients

func (r *Registry) ListClients() ([]*ClientInfo, error)

func (*Registry) Register

func (r *Registry) Register(client *ClientInfo) error

func (*Registry) Watch

func (r *Registry) Watch() (*etcdv3.Watcher, error)

type Server

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

func NewServer

func NewServer(client *etcdv3.Client) *Server

func (*Server) Bootstrap

func (s *Server) Bootstrap() error

func (*Server) GetJobs

func (s *Server) GetJobs() *Jobs

func (*Server) GetRegistry

func (s *Server) GetRegistry() *Registry

func (*Server) GetWorks

func (s *Server) GetWorks() *Works

func (*Server) Stop

func (s *Server) Stop()

type Work

type Work struct {
	ID          string
	JobId       string
	ClientId    string
	HandlerName string
	Time        int64
	Status      int
}

type Works

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

func (*Works) ClientWork

func (w *Works) ClientWork(clientId string) ([]*Work, error)

func (*Works) Watch

func (w *Works) Watch() (*etcdv3.Watcher, error)

Jump to

Keyboard shortcuts

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