Documentation
¶
Index ¶
- func NewScaler(pool *Pool)
- type Context
- func (ctx *Context) Close() error
- func (ctx *Context) Deadline() (deadline time.Time, ok bool)
- func (ctx *Context) Done() <-chan struct{}
- func (ctx *Context) Err() error
- func (ctx *Context) Error() string
- func (ctx *Context) Read(p []byte) (n int, err error)
- func (ctx *Context) Root() context.Context
- func (ctx *Context) Value(key any, val any) any
- func (ctx *Context) WG(idx int, val int) *sync.WaitGroup
- func (ctx *Context) Wait(idx int) (err error)
- func (ctx *Context) Write(p []byte) (n int, err error)
- type Fibonacci
- type Job
- type Pool
- type RetriableJob
- type Retrier
- type Scaler
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is a wrapper around native the Go context type, while adding functionality to improve developer ergonomics.
func (*Context) Error ¶
Error implements Go's native error interface and wraps errnie around it to provide more context and more flexible output.
type Fibonacci ¶
type Fibonacci struct {
// contains filtered or unexported fields
}
Fibonacci is a RetryStategy that retries a function n times with a Fibonacci interval in seconds between retries.
type Job ¶
type Job interface {
Do() error
}
Job is an interface any type can implement if they want to be able to use the generics goroutine pool.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a set of Worker types, each running their own (pre-warmed) goroutine. Any object that implements the Job interface is able to schedule work on the worker pool, which keeps the amount of goroutines in check, while still being able to benefit from high concurrency in all kinds of scenarios.
func NewPool ¶
NewPool instantiates a worker pool with bound size of maxWorkers, taking in a Context type to be able to cleanly cancel all of the sub processes it starts.
type RetriableJob ¶
type RetriableJob struct {
// contains filtered or unexported fields
}
RetriableJob provides boilerplate for quickly building jobs that retry based on a backoff delay strategy.
func (RetriableJob) Do ¶
func (job RetriableJob) Do() error
Do the job and retry x amount of times when needed.
type Retrier ¶
Retrier is an interface that can be implemented by any object that wants to schedule itself onto a worker pool and be retried under certain conditions.
func NewFibonacci ¶
func NewRetrier ¶
type Scaler ¶
type Scaler struct {
// contains filtered or unexported fields
}
Scaler is a process that evaluates the resource load of a Pool and adds or removes Workers according to its opinion about how to divide the machine resources available.