decorator

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IDecorator

type IDecorator interface {
	Decorate(method func(args ...interface{}) (interface{}, error)) func(args ...interface{}) (interface{}, error)
}

IDecorator is the interface for decorators.

type LimiterDecorator

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

LimiterDecorator manages rate limiting for decorated functions.

func NewLimiterDecorator

func NewLimiterDecorator(rateLimit time.Duration, maxConcurrent int) *LimiterDecorator

NewLimiterDecorator initializes a LimiterDecorator with specified options.

func (*LimiterDecorator) Decorate

func (d *LimiterDecorator) Decorate(method func(args ...interface{}) (interface{}, error)) func(args ...interface{}) (interface{}, error)

Decorate wraps the given method with rate limiting.

func (*LimiterDecorator) DisableLimiter

func (d *LimiterDecorator) DisableLimiter()

DisableLimiter deactivates the rate limiter.

func (*LimiterDecorator) EnableLimiter

func (d *LimiterDecorator) EnableLimiter()

EnableLimiter activates the rate limiter.

type RetryDecorator

type RetryDecorator struct {
	TenSecondlyRolling     string
	SecondlyLimitMessage   string
	RetryTimeout           map[int]time.Duration
	NumberOfApiCallRetries int
}

RetryDecorator struct to handle retry logic

func NewRetryDecorator

func NewRetryDecorator(numberOfApiCallRetries int) *RetryDecorator

NewRetryDecorator initializes a RetryDecorator with specified retries

func (*RetryDecorator) Decorate

func (d *RetryDecorator) Decorate(method func(args ...interface{}) (interface{}, error)) func(args ...interface{}) (interface{}, error)

Decorate wraps a method with retry logic

Jump to

Keyboard shortcuts

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