Documentation
¶
Index ¶
- Constants
- Variables
- func NewPool[T any](options ...Option) (*workerPool[T], error)
- type CyclicDistributionEventChain
- func (tp *CyclicDistributionEventChain[T]) BorrowOne() (*EventChannel[T], error)
- func (tp *CyclicDistributionEventChain[T]) ReportMetrics() CyclicEventChainReportMetric
- func (tp *CyclicDistributionEventChain[T]) ReturnOne(jc *EventChannel[T]) error
- func (tp *CyclicDistributionEventChain[T]) Start(eventHandler EventHander[T])
- func (tp *CyclicDistributionEventChain[T]) Stop()
- type CyclicEventChainReportMetric
- type EventChannel
- type EventHander
- type Option
- type Options
- type WorkPoolMetrics
- type WorkerFunc
Constants ¶
View Source
const DefaultCleanIntervalTime = time.Second
View Source
const DefaultConcurrency = 256 * 1024
Variables ¶
View Source
var ( NotValidJobChan = errors.New("not valid job chan now") NullJobChan = errors.New("null job chan") )
View Source
var ( // ErrInvalidMaxIdle will be returned when setting a negative number as the periodic duration to purge goroutines. ErrInvalidMaxIdle = errors.New("invalid max idle for pool") )
View Source
var Logger = log4go.LoggerManager.GetLogger("gohutool.boot4go.routine")
Functions ¶
Types ¶
type CyclicDistributionEventChain ¶ added in v1.0.8
type CyclicDistributionEventChain[T any] struct { // contains filtered or unexported fields }
func NewCyclicDistributionEventChain ¶ added in v1.0.7
func NewCyclicDistributionEventChain[T any](cyclicSize int) *CyclicDistributionEventChain[T]
func (*CyclicDistributionEventChain[T]) BorrowOne ¶ added in v1.0.8
func (tp *CyclicDistributionEventChain[T]) BorrowOne() (*EventChannel[T], error)
func (*CyclicDistributionEventChain[T]) ReportMetrics ¶ added in v1.0.8
func (tp *CyclicDistributionEventChain[T]) ReportMetrics() CyclicEventChainReportMetric
func (*CyclicDistributionEventChain[T]) ReturnOne ¶ added in v1.0.8
func (tp *CyclicDistributionEventChain[T]) ReturnOne(jc *EventChannel[T]) error
func (*CyclicDistributionEventChain[T]) Start ¶ added in v1.0.8
func (tp *CyclicDistributionEventChain[T]) Start(eventHandler EventHander[T])
func (*CyclicDistributionEventChain[T]) Stop ¶ added in v1.0.8
func (tp *CyclicDistributionEventChain[T]) Stop()
type CyclicEventChainReportMetric ¶ added in v1.0.8
type EventChannel ¶ added in v1.0.7
type EventChannel[T any] struct { // contains filtered or unexported fields }
func (*EventChannel[T]) AddEvent ¶ added in v1.0.7
func (jc *EventChannel[T]) AddEvent(one *T)
func (*EventChannel[T]) ID ¶ added in v1.0.7
func (jc *EventChannel[T]) ID() int
type EventHander ¶ added in v1.0.7
type EventHander[T any] func(job EventChannel[T], t *T) error
type Option ¶
type Option func(opts *Options)
Option represents the optional function.
func WithLogAllErrors ¶
WithLogAllErrors indicates whether it should malloc for workers.
func WithMaxIdleWorkerDuration ¶
WithMaxIdleWorkerDuration sets up the interval time of cleaning up goroutines.
func WithMaxWorkersCount ¶
WithMaxWorkersCount sets up the maximum number of goroutines that are blocked when it reaches the capacity of pool.
func WithOptions ¶
WithOptions accepts the whole Options config.
type Options ¶
type Options struct {
// MaxIdleWorkerDuration is a period for the scavenger goroutine to clean up those expired workers,
// the scavenger scans all workers every `MaxIdleWorkerDuration` and clean up those workers that haven't been
// used for more than `ExpiryDuration`.
MaxIdleWorkerDuration time.Duration
// Max number of goroutine blocking on pool.Submit.
// 0 (default value) means no such limit.
MaxWorkersCount uint32
LogAllErrors bool
}
Options contains all options which will be applied when instantiating an ants pool.
func LoadOptions ¶
type WorkPoolMetrics ¶ added in v1.0.7
type WorkPoolMetrics struct {
MaxWorkersCount uint32 `json:"max_workers_count,omitempty"`
LogAllErrors bool `json:"log_all_errors,omitempty"`
MaxIdleWorkerDuration time.Duration `json:"max_idle_worker_duration,omitempty"`
Ready int `json:"ready,omitempty"`
GetTimes uint64 `json:"get_times,omitempty"`
PurgeTimes uint64 `json:"purge_times,omitempty"`
// contains filtered or unexported fields
}
type WorkerFunc ¶
type WorkerFunc func() error
Click to show internal directories.
Click to hide internal directories.