Documentation
¶
Index ¶
- Variables
- type DefaultInvokable
- func (invokableSelf *DefaultInvokable[T]) Invoke(val T)
- func (invokableSelf *DefaultInvokable[T]) InvokeWithTimeout(val T, timeout time.Duration) error
- func (invokableSelf *DefaultInvokable[T]) SetCallee(callee func(T)) *DefaultInvokable[T]
- func (invokableSelf *DefaultInvokable[T]) SetWorkerPool(workerPool WorkerPool) *DefaultInvokable[T]
- type DefaultWorkerPool
- func (workerPoolSelf *DefaultWorkerPool) Close()
- func (workerPoolSelf *DefaultWorkerPool) IsClosed() bool
- func (workerPoolSelf *DefaultWorkerPool) PreAllocWorkerSize(preAllocWorkerSize int)
- func (workerPoolSelf *DefaultWorkerPool) Schedule(fn func()) error
- func (workerPoolSelf *DefaultWorkerPool) ScheduleWithTimeout(fn func(), timeout time.Duration) error
- func (workerPoolSelf *DefaultWorkerPool) SetDefaultWorkerPoolSettings(defaultWorkerPoolSettings DefaultWorkerPoolSettings) *DefaultWorkerPool
- func (workerPoolSelf *DefaultWorkerPool) SetIsJobQueueClosedWhenClose(isJobQueueClosedWhenClose bool) *DefaultWorkerPool
- func (workerPoolSelf *DefaultWorkerPool) SetJobQueue(jobQueue *fpgo.BufferedChannelQueue[func()]) *DefaultWorkerPool
- func (workerPoolSelf *DefaultWorkerPool) SetPanicHandler(panicHandler func(interface{})) *DefaultWorkerPool
- func (workerPoolSelf *DefaultWorkerPool) SetScheduleRetryInterval(scheduleRetryInterval time.Duration) *DefaultWorkerPool
- func (workerPoolSelf *DefaultWorkerPool) SetSpawnWorkerDuration(spawnWorkerDuration time.Duration) *DefaultWorkerPool
- func (workerPoolSelf *DefaultWorkerPool) SetWorkerBatchSize(workerBatchSize int) *DefaultWorkerPool
- func (workerPoolSelf *DefaultWorkerPool) SetWorkerExpiryDuration(workerExpiryDuration time.Duration) *DefaultWorkerPool
- func (workerPoolSelf *DefaultWorkerPool) SetWorkerJamDuration(workerJamDuration time.Duration) *DefaultWorkerPool
- func (workerPoolSelf *DefaultWorkerPool) SetWorkerSizeMaximum(workerSizeMaximum int) *DefaultWorkerPool
- func (workerPoolSelf *DefaultWorkerPool) SetWorkerSizeStandBy(workerSizeStandBy int) *DefaultWorkerPool
- type DefaultWorkerPoolSettings
- type Invokable
- type WorkerPool
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWorkerPoolJobQueueIsFull WorkerPool JobQueue Is Full ErrWorkerPoolJobQueueIsFull = errors.New("workerPool JobQueue is full") // ErrWorkerPoolIsClosed WorkerPool Is Closed ErrWorkerPoolIsClosed = errors.New("workerPool is closed") // ErrWorkerPoolScheduleTimeout WorkerPool Schedule Timeout ErrWorkerPoolScheduleTimeout = errors.New("workerPool schedule timeout") )
Functions ¶
This section is empty.
Types ¶
type DefaultInvokable ¶
type DefaultInvokable[T any] struct { // contains filtered or unexported fields }
DefaultInvokable DefaultInvokable inspired by Java ExecutorService
func NewDefaultInvokable ¶
func NewDefaultInvokable[T any](workerPool WorkerPool, callee func(T)) *DefaultInvokable[T]
NewDefaultInvokable New a DefaultInvokable on the workerPool
func (*DefaultInvokable[T]) Invoke ¶
func (invokableSelf *DefaultInvokable[T]) Invoke(val T)
Invoke Invoke the job (non-blocking)
func (*DefaultInvokable[T]) InvokeWithTimeout ¶
func (invokableSelf *DefaultInvokable[T]) InvokeWithTimeout(val T, timeout time.Duration) error
InvokeWithTimeout Invoke the job with timeout (blocking, by workerPool.ScheduleWithTimeout())
func (*DefaultInvokable[T]) SetCallee ¶
func (invokableSelf *DefaultInvokable[T]) SetCallee(callee func(T)) *DefaultInvokable[T]
SetCallee Set the Callee
func (*DefaultInvokable[T]) SetWorkerPool ¶
func (invokableSelf *DefaultInvokable[T]) SetWorkerPool(workerPool WorkerPool) *DefaultInvokable[T]
SetWorkerPool Set the WorkerPool
type DefaultWorkerPool ¶
type DefaultWorkerPool struct {
// Settings
DefaultWorkerPoolSettings
// contains filtered or unexported fields
}
DefaultWorkerPool DefaultWorkerPool inspired by Java ExecutorService
func NewDefaultWorkerPool ¶
func NewDefaultWorkerPool(jobQueue *fpgo.BufferedChannelQueue[func()], settings *DefaultWorkerPoolSettings) *DefaultWorkerPool
NewDefaultWorkerPool New a DefaultWorkerPool
func (*DefaultWorkerPool) Close ¶
func (workerPoolSelf *DefaultWorkerPool) Close()
Close Close the DefaultWorkerPool
func (*DefaultWorkerPool) IsClosed ¶
func (workerPoolSelf *DefaultWorkerPool) IsClosed() bool
IsClosed Is the DefaultWorkerPool closed
func (*DefaultWorkerPool) PreAllocWorkerSize ¶
func (workerPoolSelf *DefaultWorkerPool) PreAllocWorkerSize(preAllocWorkerSize int)
PreAllocWorkerSize PreAllocate Workers
func (*DefaultWorkerPool) Schedule ¶
func (workerPoolSelf *DefaultWorkerPool) Schedule(fn func()) error
Schedule Schedule the Job
func (*DefaultWorkerPool) ScheduleWithTimeout ¶
func (workerPoolSelf *DefaultWorkerPool) ScheduleWithTimeout(fn func(), timeout time.Duration) error
ScheduleWithTimeout Schedule the Job with timeout
func (*DefaultWorkerPool) SetDefaultWorkerPoolSettings ¶
func (workerPoolSelf *DefaultWorkerPool) SetDefaultWorkerPoolSettings(defaultWorkerPoolSettings DefaultWorkerPoolSettings) *DefaultWorkerPool
SetDefaultWorkerPoolSettings Set the defaultWorkerPoolSettings
func (*DefaultWorkerPool) SetIsJobQueueClosedWhenClose ¶
func (workerPoolSelf *DefaultWorkerPool) SetIsJobQueueClosedWhenClose(isJobQueueClosedWhenClose bool) *DefaultWorkerPool
SetIsJobQueueClosedWhenClose Set is the JobQueue closed when the WorkerPool.Close()
func (*DefaultWorkerPool) SetJobQueue ¶
func (workerPoolSelf *DefaultWorkerPool) SetJobQueue(jobQueue *fpgo.BufferedChannelQueue[func()]) *DefaultWorkerPool
SetJobQueue Set the JobQueue(WARNING: if the pool has started to use, doing this is not safe)
func (*DefaultWorkerPool) SetPanicHandler ¶
func (workerPoolSelf *DefaultWorkerPool) SetPanicHandler(panicHandler func(interface{})) *DefaultWorkerPool
SetPanicHandler Set the panicHandler(handle/log panic inside workers)
func (*DefaultWorkerPool) SetScheduleRetryInterval ¶
func (workerPoolSelf *DefaultWorkerPool) SetScheduleRetryInterval(scheduleRetryInterval time.Duration) *DefaultWorkerPool
SetScheduleRetryInterval Retry interval for ScheduleWithTimeout
func (*DefaultWorkerPool) SetSpawnWorkerDuration ¶
func (workerPoolSelf *DefaultWorkerPool) SetSpawnWorkerDuration(spawnWorkerDuration time.Duration) *DefaultWorkerPool
SetSpawnWorkerDuration Set the spawnWorkerDuration(Checking repeating by the interval/duration)
func (*DefaultWorkerPool) SetWorkerBatchSize ¶
func (workerPoolSelf *DefaultWorkerPool) SetWorkerBatchSize(workerBatchSize int) *DefaultWorkerPool
SetWorkerBatchSize Set the workerBatchSize(queued jobs number that every worker could have)
func (*DefaultWorkerPool) SetWorkerExpiryDuration ¶
func (workerPoolSelf *DefaultWorkerPool) SetWorkerExpiryDuration(workerExpiryDuration time.Duration) *DefaultWorkerPool
SetWorkerExpiryDuration The worker would be dead if the worker is idle without jobs over the duration
func (*DefaultWorkerPool) SetWorkerJamDuration ¶
func (workerPoolSelf *DefaultWorkerPool) SetWorkerJamDuration(workerJamDuration time.Duration) *DefaultWorkerPool
SetWorkerJamDuration A new worker would be created if there's no available worker to do jobs over the duration
func (*DefaultWorkerPool) SetWorkerSizeMaximum ¶
func (workerPoolSelf *DefaultWorkerPool) SetWorkerSizeMaximum(workerSizeMaximum int) *DefaultWorkerPool
SetWorkerSizeMaximum Set the workerSizeMaximum
func (*DefaultWorkerPool) SetWorkerSizeStandBy ¶
func (workerPoolSelf *DefaultWorkerPool) SetWorkerSizeStandBy(workerSizeStandBy int) *DefaultWorkerPool
SetWorkerSizeStandBy Set the workerSizeStandBy
type DefaultWorkerPoolSettings ¶
type DefaultWorkerPoolSettings struct {
// contains filtered or unexported fields
}
DefaultWorkerPoolSettings Settings for DefaultWorkerPool