worker

package
v0.0.0-...-a4b71fe Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitConfig

func InitConfig(filename string) error

加载配置

func InitJobMgr

func InitJobMgr() error

初始化管理器

func InitLogSink

func InitLogSink() error

func InitRegister

func InitRegister() error

func InitScheduler

func InitScheduler()

初始化调度器

Types

type Config

type Config struct {
	EtcdEndpoints         []string `json:"etcdEndpoints"`
	EtcdDialTimeout       int      `json:"etcdDialTimeout"`
	MongodbUri            string   `json:"mongodbUri"`
	MongodbConnectTimeout int      `json:"mongodbConnectTimeout"`
	JobLogBatchSize       int      `json:"jobLogBatchSize"`
	JobLogCommitTimeout   int      `json"jobLogCommitTimeout"`
}

程序配置

var (
	// 单例
	G_config *Config
)

type JobLock

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

分布式锁(TXN事务)

func InitJobLock

func InitJobLock(jobName string, kv clientv3.KV, lease clientv3.Lease) (jobLock *JobLock)

初始化一把锁

func (*JobLock) TryLock

func (jobLock *JobLock) TryLock() (err error)

尝试上锁

func (*JobLock) Unlock

func (jobLock *JobLock) Unlock()

释放锁

type JobMgr

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

任务管理器

var G_jobMgr *JobMgr

func (*JobMgr) CreateJobLock

func (jobMgr *JobMgr) CreateJobLock(jobName string) *JobLock

创建任务执行锁

type LogSink

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

mongodb存储日志

var G_logSink *LogSink

func (*LogSink) Append

func (logSink *LogSink) Append(jobLog *common.JobLog)

发送日志

type Register

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

注册节点到etcd: /cron/workers/IP地址

var G_register *Register

type Scheduler

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

任务调度

var (
	G_scheduler *Scheduler
)

func (*Scheduler) ExecuteJob

func (scheduler *Scheduler) ExecuteJob(info *common.JobExecuteInfo)

func (*Scheduler) PushJobEvent

func (scheduler *Scheduler) PushJobEvent(jobEvent *common.JobEvent)

推送任务变化事件

func (*Scheduler) PushJobResult

func (scheduler *Scheduler) PushJobResult(jobResult *common.JobExecuteResult)

回传任务执行结果

func (*Scheduler) TrySchedule

func (scheduler *Scheduler) TrySchedule() time.Duration

重新计算任务调度状态

func (*Scheduler) TryStartJob

func (scheduler *Scheduler) TryStartJob(jobPlan *common.JobSchedulePlan)

尝试执行任务

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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