timelimiter

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultTimeoutDuration = time.Second

Variables

This section is empty.

Functions

func DecorateConsumer

func DecorateConsumer[T any](limiter TimeLimiter, fn consumer.Consumer[T]) consumer.Consumer[T]

func DecorateFunction

func DecorateFunction[T any, R any](limiter TimeLimiter, fn function.Function[T, R]) function.Function[T, R]

func DecorateRunnable

func DecorateRunnable(limiter TimeLimiter, fn runnable.Runnable) runnable.Runnable

func DecorateSupplier

func DecorateSupplier[T any](limiter TimeLimiter, fn supplier.Supplier[T]) supplier.Supplier[T]

Types

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 WithTimeoutDuration

func WithTimeoutDuration(timeoutDuration time.Duration) ConfigBuilder

type Event

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

type EventConsumer

type EventConsumer func(Event)

type EventListener

type EventListener interface {
	OnSuccess(EventConsumer) EventListener
	OnTimeout(EventConsumer) EventListener
	OnFailure(EventConsumer) EventListener
	Dismiss(EventConsumer) EventListener
	HasConsumer() bool
	// contains filtered or unexported methods
}

type EventType

type EventType string
const (
	SUCCESS EventType = "SUCCESS"
	TIMEOUT EventType = "TIMEOUT"
	FAILURE EventType = "FAILURE"
)

type Metrics

type Metrics interface {
	SuccessCount() int64
	TimeoutCount() int64
	FailureCount() int64
	// contains filtered or unexported methods
}

type TimeLimiter

type TimeLimiter interface {
	Name() string
	Metrics() Metrics
	EventListener() EventListener
	// contains filtered or unexported methods
}

func NewTimeLimiter

func NewTimeLimiter(name string, configs ...ConfigBuilder) TimeLimiter

type TimeoutError

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

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

Jump to

Keyboard shortcuts

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