task

package
v1.2.2 Latest Latest
Warning

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

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

Documentation

Overview

* @Author: cnzf1 * @Date: 2023-03-27 19:23:22 * @LastEditors: cnzf1 * @LastEditTime: 2023-03-27 19:23:22 * @Description:

* @Author: cnzf1 * @Date: 2023-03-27 19:23:22 * @LastEditors: cnzf1 * @LastEditTime: 2023-03-30 17:34:31 * @Description:

* @Author: cnzf1 * @Date: 2023-03-27 19:23:22 * @LastEditors: cnzf1 * @LastEditTime: 2023-03-27 19:23:22 * @Description:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewJobTaskBuilder

func NewJobTaskBuilder(store Store) *jobGroupBuilder

Types

type Job

type Job struct {
	JobID     string
	GroupID   string
	BeginTime string
	EndTime   string
	Timeout   time.Duration
	Seq       int
	Status    JobStatus

	FnIn  lang.AnyType
	FnOut lang.AnyType
	// contains filtered or unexported fields
}

func (*Job) Run

func (j *Job) Run(store Store)

func (*Job) RunLocked

func (j *Job) RunLocked(store Store)

func (*Job) UpdateStatus

func (j *Job) UpdateStatus(store Store, status JobStatus)

type JobFunc

type JobFunc func(jobID string, in lang.AnyType, out *lang.AnyType) error

type JobGroup

type JobGroup struct {
	GroupID string

	CreateTime string
	Jobs       []*Job
	JobCount   int
	Sync       bool
	// contains filtered or unexported fields
}

func (*JobGroup) CreateJob

func (t *JobGroup) CreateJob(fx JobFunc, fnin lang.AnyType, timeout time.Duration) (jobID string)

func (*JobGroup) Get

func (t *JobGroup) Get(jobID string) (lang.AnyType, bool)

func (*JobGroup) GetAll

func (t *JobGroup) GetAll(grpID string) []lang.AnyType

func (*JobGroup) Keys added in v1.2.2

func (t *JobGroup) Keys() []string

func (*JobGroup) Run

func (t *JobGroup) Run()

type JobStatus

type JobStatus int8
const (
	JOB_STATUS_FAILED  JobStatus = -1 // 失败
	JOB_STATUS_TIMEOUT JobStatus = -2 // 超时
	JOB_STATUS_CREATED JobStatus = 0  // 已创建
	JOB_STATUS_RUNNING JobStatus = 1  // 运行中
	JOB_STATUS_SUCCESS JobStatus = 2  // 成功
)

func (JobStatus) String

func (i JobStatus) String() string

type KeyGenerator

type KeyGenerator interface {
	Generate() []byte
}

func NewTimeBasedRandomGenerator

func NewTimeBasedRandomGenerator(length int) KeyGenerator

type LocalStore

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

func (*LocalStore) Add

func (s *LocalStore) Add(grpID string, jobID string, data lang.AnyType) error

func (*LocalStore) Clear

func (s *LocalStore) Clear() error

func (*LocalStore) Delete

func (s *LocalStore) Delete(jobID string) error

func (*LocalStore) Get

func (s *LocalStore) Get(jobID string) (lang.AnyType, bool)

func (*LocalStore) GetAll

func (s *LocalStore) GetAll(grpID string) []lang.AnyType

func (*LocalStore) GetStatus

func (s *LocalStore) GetStatus(jobID string) int

func (*LocalStore) Update

func (s *LocalStore) Update(jobID string, data lang.AnyType) error

func (*LocalStore) UpdateStatus

func (s *LocalStore) UpdateStatus(jobID string, status int) error

type Store

type Store interface {
	Add(grpID string, jobID string, data lang.AnyType) error
	Get(jobID string) (lang.AnyType, bool)
	GetAll(grpID string) []lang.AnyType
	GetStatus(jobID string) int
	Update(jobID string, data lang.AnyType) error
	UpdateStatus(jobID string, status int) error
	Delete(jobID string) error
	Clear() error
}

func NewLocalStore

func NewLocalStore() Store

Jump to

Keyboard shortcuts

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