Documentation
¶
Overview ¶
Package pooling implements the wayback workers pool.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrPoolNotExist = errors.New("pool not exist") // ErrPoolNotExist pool not exist ErrTimeout = errors.New("process timeout") // ErrTimeout process timeout )
Functions ¶
This section is empty.
Types ¶
type Bucket ¶ added in v0.18.0
type Bucket struct { // Request is the main func for handling wayback requests. Request func(context.Context) error // Fallback defines an optional func to return a failure response for the Request func. Fallback func(context.Context) error // contains filtered or unexported fields }
A Bucket represents a wayback request is sent by a service.
type Option ¶ added in v0.19.0
type Option func(*Options)
Option is a function that modifies the provided Options instance.
func Capacity ¶ added in v0.19.0
Capacity returns an Option function that sets the capacity value for the Options. The given capacity value will be applied when the returned function is called.
func MaxRetries ¶ added in v0.19.0
MaxRetries returns an Option function that sets the maximum retries value for the Options. The given maximum retries value will be applied when the returned function is called.
type Options ¶ added in v0.19.0
type Options struct { Timeout time.Duration // Timeout specifies the maximum amount of time to wait for an operation to complete. MaxRetries uint64 // MaxRetries specifies the maximum number of times to retry the operation in case of failure. Capacity int // Capacity specifies the maximum number of items that can be processed simultaneously. }
Options represents configuration for pooling.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool represents a pool of services.
func New ¶
New a resource pool of the specified capacity Resources are created concurrently to save resource initialization time
func (*Pool) Close ¶ added in v0.16.0
func (p *Pool) Close()
Close closes the worker pool, and it is blocked until all workers are idle.
func (*Pool) Closed ¶ added in v0.19.0
Closed returns whether the pooling is closed. It uses a select with a timeout of 3 seconds to check if the p.closed channel has been closed.