job

package
v0.0.0-...-d13da26 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CronJobBuilder

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

func NewCronJobBuilder

func NewCronJobBuilder(l logger.LoggerV1) *CronJobBuilder

func (*CronJobBuilder) Build

func (b *CronJobBuilder) Build(job Job) cron.Job

type Executor

type Executor interface {
	// Executor 叫什么
	Name() string
	// Exec ctx 是整个任务调度的上下文
	// 当从 ctx.Done 有信号的时候,就需要考虑结束执行
	// 具体实现来控制
	// 真正去执行一个任务
	Exec(ctx context.Context, j domain.Job) error
}

type Job

type Job interface {
	Name() string
	Run() error
}

type LocalFuncExecutor

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

func NewLocalFuncExecutor

func NewLocalFuncExecutor() *LocalFuncExecutor

func (*LocalFuncExecutor) Exec

func (l *LocalFuncExecutor) Exec(ctx context.Context, j domain.Job) error

func (*LocalFuncExecutor) Name

func (l *LocalFuncExecutor) Name() string

func (*LocalFuncExecutor) RegisterFunc

func (l *LocalFuncExecutor) RegisterFunc(name string, fn func(ctx context.Context, j domain.Job) error)

type RankingJob

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

func NewRankingJob

func NewRankingJob(svc service.RankingService,
	client *rlock.Client,
	l logger.LoggerV1,
	timeout time.Duration) *RankingJob

func (*RankingJob) Close

func (r *RankingJob) Close() error

func (*RankingJob) Name

func (r *RankingJob) Name() string

func (*RankingJob) Run

func (r *RankingJob) Run() error

按时间调度的,三分钟一次

type RankingJobAdapter

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

func NewRankingJobAdapter

func NewRankingJobAdapter(j Job, l logger.LoggerV1) *RankingJobAdapter

func (*RankingJobAdapter) Run

func (r *RankingJobAdapter) Run()

type Scheduler

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

Scheduler 调度器

func NewScheduler

func NewScheduler(svc service.JobService, l logger.LoggerV1) *Scheduler

func (*Scheduler) RegisterExecutor

func (s *Scheduler) RegisterExecutor(exec Executor)

func (*Scheduler) Schedule

func (s *Scheduler) Schedule(ctx context.Context) error

Jump to

Keyboard shortcuts

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