ratelimiter

package
v0.0.0-...-da4b772 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TunedRateLimitMetric = prometheus.NewGaugeVec(
	prometheus.GaugeOpts{
		Namespace: config.AppName,
		Subsystem: "ratelimiter_auto_tune",
		Name:      "tuned_rate_limit",
		Help:      "The current auto-tuned rate limit for an upstream",
	},
	[]string{"upstream", "period"},
)

Functions

This section is empty.

Types

type FixedRateLimiterType

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

func NewFixedRateLimiterType

func NewFixedRateLimiterType(requests int, period time.Duration) *FixedRateLimiterType

type RateLimitBudget

type RateLimitBudget struct {
	Name   string
	Rules  []Rule
	Engine RateLimitEngine
}

func NewRateLimitBudget

func NewRateLimitBudget(config *config.RateLimitBudget, engine RateLimitEngine) *RateLimitBudget

func (*RateLimitBudget) Allow

func (b *RateLimitBudget) Allow(method string) (bool, error)

type RateLimitBudgetRegistry

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

func NewRateLimitBudgetRegistry

func NewRateLimitBudgetRegistry(cfg []config.RateLimitBudgetsConfig, storageRegistry *storages.StorageRegistry) (*RateLimitBudgetRegistry, error)

func (*RateLimitBudgetRegistry) Get

type RateLimitCommand

type RateLimitCommand struct {
	Type RateLimiterType
	Name string
}

type RateLimitEngine

type RateLimitEngine interface {
	Execute([]RateLimitCommand) (bool, error)
}

type RateLimitMemoryEngine

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

func NewRateLimitMemoryEngine

func NewRateLimitMemoryEngine() *RateLimitMemoryEngine

func (*RateLimitMemoryEngine) Execute

func (e *RateLimitMemoryEngine) Execute(cmd []RateLimitCommand) (bool, error)

type RateLimitRedisEngine

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

func NewRateLimitRedisEngine

func NewRateLimitRedisEngine(name string, redis *redis.Client) *RateLimitRedisEngine

func (*RateLimitRedisEngine) Execute

func (e *RateLimitRedisEngine) Execute(cmd []RateLimitCommand) (bool, error)

type RateLimiterType

type RateLimiterType interface {
	// contains filtered or unexported methods
}

type Rule

type Rule struct {
	Check ruleCheck
	Type  RateLimiterType
}

type UpstreamAutoTune

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

func NewUpstreamAutoTune

func NewUpstreamAutoTune(ctx context.Context, upstreamId string, config *config.RateLimitAutoTuneConfig) *UpstreamAutoTune

func (*UpstreamAutoTune) Allow

func (u *UpstreamAutoTune) Allow() bool

func (*UpstreamAutoTune) IncErrors

func (u *UpstreamAutoTune) IncErrors()

func (*UpstreamAutoTune) RecalculateRateLimit

func (u *UpstreamAutoTune) RecalculateRateLimit(ctx context.Context)

func (*UpstreamAutoTune) Run

func (u *UpstreamAutoTune) Run(ctx context.Context)

Jump to

Keyboard shortcuts

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