task

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 7 Imported by: 6

Documentation

Index

Constants

View Source
const (
	StatusPrepare = iota
	StatusProcess
	StatusCancel
	StatusFinish
)
View Source
const POOL = "pool"
View Source
const TASK = "task"
View Source
const WORK = "work"

Variables

This section is empty.

Functions

func Init

func Init(conf *conf.Conf)

func Put

func Put(meta Meta, param Any, action func(*Task))

func Wait

func Wait(meta Meta, params []Any, action func(*Task, *Lock) error)

func WaitN added in v0.6.7

func WaitN(meta Meta, n int, action func(*Task, *Lock) error)

Types

type Any added in v0.6.4

type Any = interface{}

type Lock

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

func (*Lock) Lock added in v0.6.4

func (lock *Lock) Lock() func()

func (*Lock) Locks added in v0.8.2

func (lock *Lock) Locks(cb func())

func (*Lock) RLock

func (lock *Lock) RLock() func()

type Meta added in v0.7.12

type Meta struct {
	Prefix   string
	FileLine string
}

type Pool

type Pool struct {
	Logger func(...Any)
	// contains filtered or unexported fields
}

func New

func New(conf *conf.Conf) *Pool

func (*Pool) Close

func (pool *Pool) Close()

func (*Pool) Put

func (pool *Pool) Put(meta Meta, params Any, action func(*Task))

func (*Pool) Wait

func (pool *Pool) Wait(meta Meta, args []Any, action func(*Task, *Lock) error)

func (*Pool) WaitN added in v0.6.4

func (pool *Pool) WaitN(meta Meta, n int, action func(*Task, *Lock) error)

type Task

type Task struct {
	Action func(*Task)
	Params Any
	Meta   Meta

	Error  Any
	Status int

	PrepareTime time.Time
	ProcessTime time.Time
	FinishTime  time.Time

	Logger func(...Any)
	// contains filtered or unexported fields
}

func (*Task) Context added in v0.6.4

func (task *Task) Context() context.Context

func (*Task) Info

func (task *Task) Info() string

func (*Task) Pool

func (task *Task) Pool() *Pool

func (*Task) Run

func (task *Task) Run(ctx context.Context)

func (*Task) TaskId added in v1.0.1

func (task *Task) TaskId() int64

func (*Task) WorkId added in v1.0.1

func (task *Task) WorkId() int64

type Work

type Work struct {
	Logger func(...Any)
	// contains filtered or unexported fields
}

func (*Work) Info added in v0.6.4

func (work *Work) Info() string

func (*Work) Run

func (work *Work) Run(ctx context.Context)

Jump to

Keyboard shortcuts

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