mysql

package
v0.0.0-...-fb7a588 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithPreemptInterval

func WithPreemptInterval(t time.Duration) option.Option[Storage]

func WithPreemptTimeout

func WithPreemptTimeout(t time.Duration) option.Option[Storage]

func WithRefreshInterval

func WithRefreshInterval(t time.Duration) option.Option[Storage]

func WithRefreshRetry

func WithRefreshRetry(r storage.RetryStrategy) option.Option[Storage]

Types

type Storage

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

func NewMysqlStorage

func NewMysqlStorage(dsn string, opt ...option.Option[Storage]) (*Storage, error)

func (*Storage) Add

func (s *Storage) Add(ctx context.Context, t *task.Task) (int64, error)

Add 创建task,设置调度状态是created

func (*Storage) AddExecution

func (s *Storage) AddExecution(ctx context.Context, taskId int64) (int64, error)

AddExecution 创建一条执行记录

func (*Storage) AutoLookup

func (s *Storage) AutoLookup(ctx context.Context)

func (*Storage) AutoRefresh

func (s *Storage) AutoRefresh(ctx context.Context)

func (*Storage) CompareAndUpdateTaskExecutionStatus

func (s *Storage) CompareAndUpdateTaskExecutionStatus(ctx context.Context, taskId int64, old, new string) error

func (*Storage) CompareAndUpdateTaskStatus

func (s *Storage) CompareAndUpdateTaskStatus(ctx context.Context, taskId int64, old, new string) error

func (*Storage) Delete

func (s *Storage) Delete(ctx context.Context, taskId int64) error

func (*Storage) Events

func (s *Storage) Events(ctx context.Context, taskEvents <-chan task.Event) (<-chan storage.Event, error)

func (*Storage) Get

func (s *Storage) Get(ctx context.Context, taskId int64) (*task.Task, error)

func (*Storage) RunPreempt

func (s *Storage) RunPreempt(ctx context.Context)

RunPreempt 每隔固定时间去db中抢占任务

func (*Storage) Stop

func (s *Storage) Stop(ctx context.Context) error

Stop storage的关闭, 这里终止所有正在执行的任务

func (*Storage) Update

func (s *Storage) Update(ctx context.Context, t *task.Task) error

type StorageInfo

type StorageInfo struct {
	Id               int64  `eorm:"auto_increment,primary_key"`
	OccupierPayload  int64  // 该storage的占有者负载
	CandidatePayload int64  // 该storage的候选者负载
	Status           string // 该storage状态
}

type TaskExecution

type TaskExecution struct {
	Id            int64 `eorm:"auto_increment,primary_key"`
	TaskId        int64
	ExecuteStatus string
	CreateTime    int64
	UpdateTime    int64
}

type TaskInfo

type TaskInfo struct {
	Id              int64 `eorm:"auto_increment,primary_key"`
	Name            string
	SchedulerStatus string
	Epoch           int64
	Cron            string
	Type            string
	Config          string
	OccupierId      int64 // 占有该任务的storage
	CandidateId     int64 // 该任务的候选storage
	CreateTime      int64
	UpdateTime      int64
}

Jump to

Keyboard shortcuts

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