Documentation
¶
Overview ¶
Package pooling implements the wayback workers pool.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
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 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) Roll ¶
func (p *Pool) Roll()
Roll process wayback requests from the resource pool for execution.
// Stream generates values with DoSomething and sends them to out
// until DoSomething returns an error or ctx.Done is closed.
func Stream(ctx context.Context, out chan<- Value) error {
for {
v, err := DoSomething(ctx)
if err != nil {
return err
}
select {
case <-ctx.Done():
return ctx.Err()
case out <- v:
}
}
}
Click to show internal directories.
Click to hide internal directories.