ratelimit

package
v0.9.26 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpenAIRPM     = 3500 // Requests per minute
	OpenAIBurst   = 10   // Burst allowance
	SentinelRPM   = 0    // Unlimited (OSS models)
	OllamaRPM     = 0    // Unlimited (local)
	HuggingFaceRP = 0    // Unlimited (local sentence-transformers)
)

OpenAI rate limits (per minute)

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

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

Limiter wraps rate.Limiter with provider-specific limits

func NewLimiter

func NewLimiter(embeddingModel string) *Limiter

NewLimiter creates a rate limiter for the given embedding provider

func NewUnlimitedLimiter

func NewUnlimitedLimiter() *Limiter

NewUnlimitedLimiter creates a limiter with no rate restrictions

func (*Limiter) Allow

func (l *Limiter) Allow() bool

Allow checks if an action can proceed without blocking

func (*Limiter) Burst

func (l *Limiter) Burst() int

Burst returns the maximum burst size

func (*Limiter) Enabled

func (l *Limiter) Enabled() bool

Enabled returns true if rate limiting is active

func (*Limiter) Limit

func (l *Limiter) Limit() rate.Limit

Limit returns the current rate limit (requests per second)

func (*Limiter) Provider

func (l *Limiter) Provider() string

Provider returns the detected provider name

func (*Limiter) SetRateLimit

func (l *Limiter) SetRateLimit(requestsPerMinute int)

SetRateLimit updates the rate limit dynamically

func (*Limiter) Tokens

func (l *Limiter) Tokens() float64

Tokens returns the current number of available tokens

func (*Limiter) Wait

func (l *Limiter) Wait(ctx context.Context) error

Wait blocks until the rate limiter allows an action

Jump to

Keyboard shortcuts

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