utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimiter

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

RateLimiter provides rate limiting functionality for API calls

func NewRateLimiter

func NewRateLimiter() *RateLimiter

NewRateLimiter creates a new rate limiter

func (*RateLimiter) GetUsage

func (rl *RateLimiter) GetUsage(provider string) map[string]interface{}

GetUsage returns the current usage statistics

func (*RateLimiter) RecordRequest

func (rl *RateLimiter) RecordRequest(provider string, tokenCount int)

RecordRequest records that a request was made

func (*RateLimiter) RegisterProvider

func (rl *RateLimiter) RegisterProvider(provider string, requestsPerMin, tokensPerMin int)

RegisterProvider registers a provider with rate limits

func (*RateLimiter) Wait

func (rl *RateLimiter) Wait(ctx context.Context, provider string) error

Wait blocks until a request can be made according to rate limits

Jump to

Keyboard shortcuts

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