Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool 协程池
func NewPool ¶
func NewPool(ctx context.Context, cfg config.PoolConfig, handler RejectedHandler, workerHook []WorkerStatusChangeHook, poolHook []PoolStatusChangeHook) (*Pool, error)
func (*Pool) GoWithTimeout ¶
type PoolStatus ¶
type PoolStatus int64
const ( PoolStatusInit PoolStatus = iota + 1 // 初始化中 PoolStatusWorking // 运行中 PoolStatusShutdown // 关闭状态,不接受新的任务,执行完已有任务后终止 PoolStatusStop // 中断状态 PoolStatusTerminated // 终止状态 )
func (PoolStatus) String ¶
func (p PoolStatus) String() string
type PoolStatusChangeHook ¶
type PoolStatusChangeHook interface {
OnChange(status PoolStatus)
}
type RejectedHandler ¶
type RejectedHandler interface {
RejectedExecution(task func())
}
RejectedHandler rejected handler
type Worker ¶
type Worker struct { Id int64 // 唯一 id FreeBeginTime time.Time // 空闲开始时间 // contains filtered or unexported fields }
Worker 执行者
func (*Worker) ResetFreeTime ¶
func (p *Worker) ResetFreeTime()
func (*Worker) ShouldTerminal ¶
ShouldTerminal check over core size
type WorkerStatus ¶
type WorkerStatus int64
const ( WorkerStatusReady WorkerStatus = iota + 1 // 就绪 WorkerStatusRunning // 运行中 WorkerStatusShutdown // 关闭状态,不拉取新的任务,执行完任务后终止 WorkerStatusStop // 中断状态,直接终止 WorkerStatusTidying // 空闲状态 WorkerStatusTerminated // 已经终止 WorkerStatusCreate )
func (WorkerStatus) String ¶
func (w WorkerStatus) String() string
type WorkerStatusChangeHook ¶
type WorkerStatusChangeHook interface {
OnChange(workerId int64, lastStatus WorkerStatus, nextStatus WorkerStatus)
}
Click to show internal directories.
Click to hide internal directories.