executor

package
v0.0.0-...-e1aa8c7 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMinWorkerQuantity is the default minWorkerQuantity
	DefaultMinWorkerQuantity = 10
	// DefaultMaxWorkerQuantity is the default maxWorkerQuantity
	DefaultMaxWorkerQuantity = 20
	// DefaultScaleUpThreshold is the default scaleUpThreshold
	DefaultScaleUpThreshold = 1 * time.Second
	// DefaultScaleDownThreshold is the default scaleDownThreshold
	DefaultScaleDownThreshold = 1 * time.Minute
)

Variables

View Source
var (
	// ErrNotChanType means object is not channel, but used as channel
	ErrNotChanType = errors.New("not chan type")
	// ErrChanClosed means the channel waited from is closed
	ErrChanClosed = errors.New("chan closed")
	// ErrTimeout means waiting is timeout
	ErrTimeout = errors.New("wait chan timeout")
	// ErrOutOfRange should never be used
	ErrOutOfRange = errors.New("index out of range") // should never happen
)

Functions

func ClearChannel

func ClearChannel(ch interface{}) error

ClearChannel clear all content in channel

func ReadChanWithTimeout

func ReadChanWithTimeout(ch interface{}, timeout time.Duration) (interface{}, error)

ReadChanWithTimeout read something from channel with timeout

func WriteChanWithTimeout

func WriteChanWithTimeout(ch interface{}, data interface{}, timeout time.Duration) error

WriteChanWithTimeout write something to channel with timeout

Types

type Autoscaler

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

Autoscaler struct

func NewAutoscaler

func NewAutoscaler(minWorkerQuantity, maxWorkerQuantity int, scaleUpThreshold, scaleDownThreshold time.Duration) *Autoscaler

NewAutoscaler return new Autoscaler object

func (*Autoscaler) ActiveWorkerCount

func (s *Autoscaler) ActiveWorkerCount() int

ActiveWorkerCount return the count of active worker

func (*Autoscaler) AddJobBlocked

func (s *Autoscaler) AddJobBlocked(job Job) error

AddJobBlocked add new job to autoscaler

func (*Autoscaler) Run

func (s *Autoscaler) Run()

Run run Autoscaler worker

func (*Autoscaler) Stop

func (s *Autoscaler) Stop()

Stop stop all Autoscaler worker

func (*Autoscaler) WaitForAllJobsDone

func (s *Autoscaler) WaitForAllJobsDone()

WaitForAllJobsDone wait for all job submitted done

type Executor

type Executor interface {
	Run()
	Stop()
	WaitForAllJobsDone()
	AddJob(job Job)
}

Executor backend interface

type Job

type Job interface {
	// Job exec
	Exec()
}

Job is the interface of the REAL JOB need to impl

Jump to

Keyboard shortcuts

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