task

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExecuting = errors.New("is executing")
View Source
var ErrOverMaxRetry = errors.New("over max retry")

Functions

This section is empty.

Types

type Awaken added in v0.2.0

type Awaken struct {
	Task       Task
	OverLapped *Task
}

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

func (Context) Callback

func (cb Context) Callback(ctx context.Context, res ExecResult) error

func (Context) ExecCount added in v0.2.0

func (cb Context) ExecCount() int32

func (Context) Task added in v0.2.0

func (cb Context) Task() Task

type Desc

type Desc struct {
	TaskKey  string
	ExecDesc ExecConfig
	Tags     []string
	Overlap  bool
}

type ExecConfig added in v0.2.0

type ExecConfig struct {
	ExpectStartTime time.Time     `bson:"expectRetryTime"`
	MaxExecDuration time.Duration `bson:"maxExecDuration"`
	RemainExecCount int32         `bson:"remainExec"`
	Priority        int32         `bson:"priority"`
}

type ExecResult

type ExecResult struct {
	ResultInfo string     `bson:"resultInfo"`
	ResultCode int64      `bson:"resultCode"`
	NextExec   ExecConfig `bson:"next,omitempty"`
}

type ExecSummery added in v0.2.0

type ExecSummery struct {
	CurrentIndex   int32
	ExpectExecTime time.Time
	MaxDuration    time.Duration
}

type Execution

type Execution struct {
	Available  bool
	Config     ExecConfig `bson:"config"`
	CreateTime time.Time  `bson:"createTime,omitempty"`
	StartTime  time.Time  `bson:"startTime,omitempty"`
	EndTime    time.Time  `bson:"endTime,omitempty"`
	Result     ExecResult `bson:"result,omitempty"`
}

func (*Execution) CanRetry added in v0.1.5

func (er *Execution) CanRetry() bool

func (*Execution) End added in v0.1.2

func (er *Execution) End(result ExecResult, t time.Time)

func (*Execution) Ended

func (er *Execution) Ended() bool

func (*Execution) Executing added in v0.1.2

func (er *Execution) Executing() bool

func (*Execution) OverExecTime added in v0.1.5

func (er *Execution) OverExecTime(t time.Time) bool

func (*Execution) ReadyToStart

func (er *Execution) ReadyToStart() bool

func (*Execution) Start added in v0.1.2

func (er *Execution) Start(t time.Time)

func (*Execution) WaitingStart

func (er *Execution) WaitingStart() bool

type Executor

type Executor interface {
	StartExecution(cb Context) error
}

type FuncExecutor

type FuncExecutor func(cb Context) error

func (FuncExecutor) StartExecution

func (fe FuncExecutor) StartExecution(cb Context) error

type Info added in v0.1.5

type Info struct {
	Tags       []string   `bson:"tags"`
	ExecConfig ExecConfig `bson:"execDesc"`
	CreateTime time.Time  `bson:"createTime"`
	ExecCount  int32      `bson:"execCount"`
}

type Manager

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

func NewManager

func NewManager(scheduler Scheduler, executor Executor, maxRedundancy time.Duration) *Manager

func (*Manager) ApplyNewTask

func (svc *Manager) ApplyNewTask(ctx context.Context, desc Desc) error

func (*Manager) Close added in v0.3.0

func (svc *Manager) Close(ctx context.Context) error

func (*Manager) CloseTask added in v0.2.0

func (svc *Manager) CloseTask(ctx context.Context, taskKey string) error

func (*Manager) TaskCallback

func (svc *Manager) TaskCallback(ctx context.Context, task Task, result ExecResult) error

type MemoScheduler

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

func NewMemoScheduler

func NewMemoScheduler(awakenDuration time.Duration) *MemoScheduler

func (*MemoScheduler) Close added in v0.3.0

func (scheduler *MemoScheduler) Close(ctx context.Context) error

func (*MemoScheduler) CloseTaskSchedule added in v0.1.5

func (scheduler *MemoScheduler) CloseTaskSchedule(ctx context.Context, task Task) error

func (*MemoScheduler) NewStageID added in v0.3.0

func (scheduler *MemoScheduler) NewStageID(ctx context.Context, taskKey string) (seq int64, err error)

func (*MemoScheduler) ReadTask added in v0.1.5

func (scheduler *MemoScheduler) ReadTask(ctx context.Context, taskKey string) (*Task, error)

func (*MemoScheduler) ScheduleTask added in v0.1.5

func (scheduler *MemoScheduler) ScheduleTask(ctx context.Context, task Task, overlap bool) (Task, error)

func (*MemoScheduler) TaskSummery added in v0.1.5

func (scheduler *MemoScheduler) TaskSummery(ctx context.Context) (*Summery, error)

func (*MemoScheduler) WaitTaskAwaken

func (scheduler *MemoScheduler) WaitTaskAwaken(ctx context.Context) (awaken Awaken, err error)

type Profile

type Profile struct {
	TaskKey    string
	Status     StatusCode
	Executions []Execution
}

type Schedule added in v0.1.5

type Schedule struct {
	AwakenTime time.Time
	Priority   int32
}

type Scheduler

type Scheduler interface {
	ScheduleTask(ctx context.Context, task Task, overlap bool) (Task, error)
	CloseTaskSchedule(ctx context.Context, task Task) error
	WaitTaskAwaken(ctx context.Context) (awaken Awaken, err error)
	ReadTask(ctx context.Context, taskKey string) (*Task, error)
	NewStageID(ctx context.Context, taskKey string) (stageID int64, err error)
	Close(ctx context.Context) error
}

type StatusCode added in v0.1.5

type StatusCode int

func (StatusCode) String added in v0.1.5

func (status StatusCode) String() string

type StatusProfile

type StatusProfile struct {
	Total    int64     `json:"total"`
	Count    int64     `json:"count"`
	Profiles []Profile `json:"profile"`
}

type Summery

type Summery struct {
	StatusCount map[StatusCode]int64
}

type Task

type Task struct {
	Key       string    `bson:"_id"`
	Stage     int64     `bson:"stage"`
	Schedule  Schedule  `bson:"schedule"`
	Info      Info      `bson:"info"`
	Execution Execution `bson:"execution"`
}

func (*Task) NewExec added in v0.2.0

func (t *Task) NewExec(stageID int64)

func (*Task) Status

func (t *Task) Status() StatusCode

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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