Documentation ¶
Index ¶
- Constants
- func DeleteGroupById(id string) (*client.DeleteResponse, error)
- func DeleteJob(group, id string) (resp *client.DeleteResponse, err error)
- func GetGroups(nid string) (groups map[string]*Group, err error)
- func GetIDFromKey(key string) string
- func GetJobs() (jobs map[string]*Job, err error)
- func GroupKey(id string) string
- func ISNodeAlive(id string) (bool, error)
- func InitEtcdClient(cfg *conf.Conf) error
- func IsValidAsKeyPath(s string) bool
- func JobKey(group, id string) string
- func NewEtcdTimeoutContext(c *Client) (context.Context, context.CancelFunc)
- func RemoveNode(query interface{}) error
- func WatchGroups() client.WatchChan
- func WatchJobs() client.WatchChan
- func WatchNode() client.WatchChan
- type Client
- func (c *Client) DelLock(key string) error
- func (c *Client) Delete(key string, opts ...client.OpOption) (*client.DeleteResponse, error)
- func (c *Client) Get(key string, opts ...client.OpOption) (*client.GetResponse, error)
- func (c *Client) GetLock(key string, id client.LeaseID) (bool, error)
- func (c *Client) Grant(ttl int64) (*client.LeaseGrantResponse, error)
- func (c *Client) KeepAliveOnce(id client.LeaseID) (*client.LeaseKeepAliveResponse, error)
- func (c *Client) Put(key, val string, opts ...client.OpOption) (*client.PutResponse, error)
- func (c *Client) PutWithModRev(key, val string, rev int64) (*client.PutResponse, error)
- func (c *Client) Revoke(id client.LeaseID) (*client.LeaseRevokeResponse, error)
- func (c *Client) Watch(key string, opts ...client.OpOption) client.WatchChan
- type Cmd
- type Group
- type Job
- type JobRule
- type Node
Constants ¶
View Source
const ( KindCommon = iota KindAlone // 任何时间段只允许单机执行 KindInterval // 一个任务执行间隔内允许执行一次 )
View Source
const (
Coll_Node = "node"
)
View Source
const (
DefaultJobGroup = "default"
)
Variables ¶
This section is empty.
Functions ¶
func DeleteGroupById ¶
func DeleteGroupById(id string) (*client.DeleteResponse, error)
func ISNodeAlive ¶
func InitEtcdClient ¶
func IsValidAsKeyPath ¶
func NewEtcdTimeoutContext ¶
func NewEtcdTimeoutContext(c *Client) (context.Context, context.CancelFunc)
NewEtcdTimeoutContext return a new etcdTimeoutContext
func RemoveNode ¶
func RemoveNode(query interface{}) error
func WatchGroups ¶
Types ¶
type Client ¶
func (*Client) KeepAliveOnce ¶
func (*Client) PutWithModRev ¶
type Group ¶
type Group struct { ID string `json:"id"` Name string `json:"name"` NodeIDs []string `json:"nids"` }
结点类型分组 注册到 /cronsun/group/<id>
func GetGroupById ¶
func GetGroupFromKv ¶
func GetNodeGroups ¶
type Job ¶
type Job struct { ID string `json:"id"` Name string `json:"name"` Group string `json:"group"` Command string `json:"cmd"` User string `json:"user"` Rules []*JobRule `json:"rules"` Pause bool `json:"pause"` // 可手工控制的状态 Timeout int64 `json:"timeout"` // 任务执行时间超时设置,大于 0 时有效 // 设置任务在单个节点上可以同时允许多少个 // 针对两次任务执行间隔比任务执行时间要长的任务启用 Parallels int64 `json:"parallels"` // 执行任务失败重试次数 // 默认为 0,不重试 Retry int `json:"retry"` // 执行任务失败重试时间间隔 // 单位秒,如果不大于 0 则马上重试 Interval int `json:"interval"` // 任务类型 // 0: 普通任务 // 1: 单机任务 // 如果为单机任务,node 加载任务的时候 Parallels 设置 1 Kind int `json:"kind"` // 平均执行时间,单位 ms AvgTime int64 `json:"avg_time"` // 执行失败发送通知 FailNotify bool `json:"fail_notify"` // 发送通知地址 To []string `json:"to"` // 单独对任务指定日志清除时间 LogExpiration int `json:"log_expiration"` // 执行任务的结点,用于记录 job log RunOn string Hostname string Ip string // 控制同时执行任务数 Count *int64 `json:"-"` // contains filtered or unexported fields }
需要执行的 cron cmd 命令 注册到 /cronsun/cmd/groupName/<id>
func GetJobFromKv ¶
type JobRule ¶
type Node ¶
type Node struct { ID string `bson:"_id" json:"id"` // machine id PID string `bson:"pid" json:"pid"` // 进程 pid PIDFile string `bson:"-" json:"-"` IP string `bson:"Ip" json:"Ip"` // node Ip Hostname string `bson:"Hostname" json:"Hostname"` Version string `bson:"version" json:"version"` UpTime time.Time `bson:"up" json:"up"` // 启动时间 DownTime time.Time `bson:"down" json:"down"` // 上次关闭时间 Alived bool `bson:"alived" json:"alived"` // 是否可用 Connected bool `bson:"-" json:"connected"` // 当 Alived 为 true 时有效,表示心跳是否正常 }
执行 cron cmd 的进程 注册到 /cronsun/node/<id>
func GetNodesBy ¶
func GetNodesByID ¶
Click to show internal directories.
Click to hide internal directories.