Documentation
¶
Overview ¶
Package bulkhead provides per-capability semaphore isolation for ability invocations.
Index ¶
- Variables
- func SetDefaults(opts ...Option)
- type Bulkhead
- type Option
- func WithMaxConcurrent(n int) Option
- func WithMaxQueue(n int) Option
- func WithOnDrop(fn func(name string, reason string)) Option
- func WithOnEnter(fn func(name string, waitDuration time.Duration)) Option
- func WithOnLeave(fn func(name string)) Option
- func WithOnQueueEnter(fn func(name string)) Option
- func WithOnQueueLeave(fn func(name string)) Option
- func WithTimeout(d time.Duration) Option
Constants ¶
This section is empty.
Variables ¶
var ErrBulkheadFull = errors.New("bulkhead: queue full")
ErrBulkheadFull is returned when the queue is at capacity and a new request cannot be accepted.
var ErrBulkheadTimeout = errors.New("bulkhead: wait timeout")
ErrBulkheadTimeout is returned when a slot cannot be acquired within the configured timeout.
Functions ¶
func SetDefaults ¶
func SetDefaults(opts ...Option)
SetDefaults sets default options applied to all Bulkhead instances created via Get. Must be called before any Get calls for the settings to take effect.
Types ¶
type Bulkhead ¶
type Bulkhead struct {
// contains filtered or unexported fields
}
Bulkhead controls concurrent access for a named resource.
type Option ¶
type Option func(*config)
Option configures a Bulkhead instance.
func WithMaxConcurrent ¶
WithMaxConcurrent sets the maximum number of concurrent slots.
func WithMaxQueue ¶
WithMaxQueue sets the maximum number of requests that can wait for a slot.
func WithOnDrop ¶
WithOnDrop sets a callback invoked when a request is dropped.
func WithOnEnter ¶
WithOnEnter sets a callback invoked when a request acquires a slot.
func WithOnLeave ¶
WithOnLeave sets a callback invoked when a request releases a slot.
func WithOnQueueEnter ¶
WithOnQueueEnter sets a callback invoked when a request enters the wait queue.
func WithOnQueueLeave ¶
WithOnQueueLeave sets a callback invoked when a request leaves the wait queue.
func WithTimeout ¶
WithTimeout sets the maximum time a request will wait for a slot.