bulkhead

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultMaxConcurrentCalls int64 = 25
View Source
const DefaultMaxWaitDuration time.Duration = 0

Variables

This section is empty.

Functions

func DecorateConsumer

func DecorateConsumer[T any](bulkhead Bulkhead, fn func(T) error) func(T) error

func DecorateFunction

func DecorateFunction[T any, R any](bulkhead Bulkhead, fn func(T) (R, error)) func(T) (R, error)

func DecorateRunnable

func DecorateRunnable(bulkhead Bulkhead, fn func() error) func() error

func DecorateSupplier

func DecorateSupplier[T any](bulkhead Bulkhead, fn func() (T, error)) func() (T, error)

Types

type Bulkhead

type Bulkhead interface {
	Name() string
	Metrics() Metrics
	EventListener() EventListener
	Acquire() error
	Release()
}

func NewBulkhead

func NewBulkhead(name string, configs ...ConfigBuilder) Bulkhead

type Config

type Config struct {
	// contains filtered or unexported fields
}

func (*Config) String

func (config *Config) String() string

type ConfigBuilder

type ConfigBuilder func(*Config)

func WithMaxConcurrentCalls

func WithMaxConcurrentCalls(maxConcurrentCalls int64) ConfigBuilder

func WithMaxWaitDuration

func WithMaxWaitDuration(maxWaitDuration time.Duration) ConfigBuilder

type Event

type Event interface {
	fmt.Stringer
	BulkheadName() string
	CreationTime() time.Time
	EventType() EventType
}

type EventListener

type EventListener interface {
	OnPermittedFunc(func(PermittedEvent)) EventListener
	OnRejectedFunc(func(RejectedEvent)) EventListener
	OnFinishedFunc(func(FinishedEvent)) EventListener
	DismissPermittedFunc(func(PermittedEvent)) EventListener
	DismissRejectedFunc(func(RejectedEvent)) EventListener
	DismissFinishedFunc(func(FinishedEvent)) EventListener

	OnPermitted(fn.Consumer[PermittedEvent]) EventListener
	OnRejected(fn.Consumer[RejectedEvent]) EventListener
	OnFinished(fn.Consumer[FinishedEvent]) EventListener
	DismissPermitted(fn.Consumer[PermittedEvent]) EventListener
	DismissRejected(fn.Consumer[RejectedEvent]) EventListener
	DismissFinished(fn.Consumer[FinishedEvent]) EventListener
}

type EventType

type EventType string
const (
	PERMITTED EventType = "PERMITTED"
	REJECTED  EventType = "REJECTED"
	FINISHED  EventType = "FINISHED"
)

type FinishedEvent added in v0.4.1

type FinishedEvent interface {
	Event
}

type FullError

type FullError struct {
	// contains filtered or unexported fields
}

func (*FullError) Error

func (e *FullError) Error() string

type Metrics

type Metrics interface {
	MaxAllowedConcurrentCalls() int64
	AvailableConcurrentCalls() int64
}

type PermittedEvent added in v0.4.1

type PermittedEvent interface {
	Event
}

type RejectedEvent added in v0.4.1

type RejectedEvent interface {
	Event
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL