Documentation ¶
Index ¶
Constants ¶
View Source
const ( StatusOK = iota StatusFailed )
View Source
const ( // KeyPrefix 前缀 KeyPrefix = "/pepper/cron" // DispatchElectionMaster 用于主从选举 DispatchElectionMaster = KeyPrefix + "/election/master" // JobConfigurationPrefix Job 配置,Agent 不用这里的 JobConfigurationPrefix = KeyPrefix + "/jobs" // JobConfiguration Job 具体的配置 Key JobConfiguration = JobConfigurationPrefix + "/%v" // JobDispatchRecord Job 分配的状态记录 JobDispatchRecord = KeyPrefix + "/dispatch/%v" // BaseJobExecutionRecordPrefix Job 执行结果记录 BaseJobExecutionRecordPrefix = KeyPrefix + "/job/execution" // JobExecutionRecordPrefix Job 执行结果记录 JobExecutionRecordPrefix = BaseJobExecutionRecordPrefix + "/%v" // JobExecutionRecord Job 执行结果记录 JobExecutionRecord = JobExecutionRecordPrefix + "/%v" //JobDispatchAgentPrefix 分配器下发给 Agent 的 Jobs JobDispatchAgentPrefix = KeyPrefix + "/agent/%v/jobs" // JobDispatchAgent 具体某个 Agent 的配置 JobDispatchAgent = JobDispatchAgentPrefix + "/%v" // AgentNodeAlivePrefix Agent KeepAlive 上报 Key AgentNodeAlivePrefix = KeyPrefix + "/agent/nodes/alive" // AgentNodeAlive 同上 AgentNodeAlive = AgentNodeAlivePrefix + "/%v" // BaseAgentExecutionRecordPrefix Agent 执行结果上报 Key BaseAgentExecutionRecordPrefix = KeyPrefix + "/agent/execution/%v" // AgentExecutionRecordPrefix 同上 AgentExecutionRecordPrefix = BaseAgentExecutionRecordPrefix + "/%v" // AgentExecutionRecord 同上 AgentExecutionRecord = AgentExecutionRecordPrefix + "/%v" // dispatch_id + node_id + group_id // Read-Only by All GlobalConfig = KeyPrefix + "/conf/global" NodeConfig = KeyPrefix + "/conf/nodes/%v" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentExecutionResult ¶
type AgentExecutionResult struct { ExecutionResult // Agent node id. AgentNode string `json:"agent_node"` // Start time of the execution. StartedAt time.Time `json:"started_at"` // When the execution finished running. FinishedAt time.Time `json:"finished_at"` // Execution status. Status int `json:"status"` // Partial output of the execution. Output string `json:"output"` }
type AgentJobConfig ¶
type AgentJobConfig struct { // Job 名 Name string `json:"name"` // DispatchID DispatchID string `json:"dispatch_id"` // Job 类型,多少次或者间隔执行 Type JobType `json:"type"` // Times 当 JobType 为 JobTypeTimes 时生效,执行次数配置 Times int64 `json:"times"` // TimesDelay 为当 Times 大于 TimesDelay time.Duration `json:"times_delay"` // Schedule 当 JobType 为 JobTypeSchedule 时生效,执行计划配置 Schedule string `json:"schedule"` // 基础 Group ID BaseGroupID int64 `json:"base_group_id"` // Timezone 时区设置,空为本地时间 Timezone string `json:"timezone"` // ExecutorBlocking 是否阻塞执行 // 当 True 时,上个计划执行的任务未完成时,本次计划将不执行 // 注意:只会在当 Type 为 JobTypeSchedule 时生效 ExecutorBlocking bool `json:"executor_blocking"` // ExecutorType 执行器类型 ExecutorType ExecutorType `json:"executor_type"` // ExecutorParams 执行器参数 ExecutorParams []string `json:"executor_params"` // ExecutorTimeout 执行器超时 ExecutorTimeout time.Duration `json:"executor_timeout"` // Extra environment variable to give to the command to execute. EnvironmentVariables []string `json:"environment_variables"` // Extras Extras map[string]string `json:"extras"` }
AgentJobConfig 定义 Agent 执行 Job 的结构
func (*AgentJobConfig) Parse ¶
func (conf *AgentJobConfig) Parse(data []byte) error
Parse 将 json 转换成 Job 对象
func (*AgentJobConfig) ToString ¶
func (conf *AgentJobConfig) ToString() (string, error)
ToString 转换成 String
type ExecutionResult ¶
type ExecutorType ¶
type ExecutorType int
ExecutorType 定义 Executor 类型
const ( // ExecutorTypeShell 表示 ExecutorType - Shell 执行器 ExecutorTypeShell ExecutorType = iota // ExecutorTypeGRPC 表示 ExecutorType - GPRC 请求执行器 ExecutorTypeGRPC // ExecutorTypeHTTP 表示 ExecutorType - HTTP 请求执行器 ExecutorTypeHTTP )
type JobCallbackFunc ¶
type JobCallbackFunc func(*AgentExecutionResult)
JobCallbackFunc Job 执行结果回调函数
type JobConfig ¶
type JobConfig struct { AgentJobConfig // Job tag Tag string `json:"tag"` // Number of times to retry a job that failed an execution. Retries uint `json:"retries"` // Jobs that are dependent upon this one will be run after this job runs. DependentJobs []string `json:"dependent_jobs"` // Concurrency policy for this job Concurrency int `json:"concurrency"` // Computed job status Status string `json:"status"` }
JobConfig describes a scheduled Job.
Click to show internal directories.
Click to hide internal directories.