fixedwindow

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: EUPL-1.2 Imports: 7 Imported by: 0

Documentation

Overview

Package fixedwindow implements a fixed-window counter rate limiter backed by Valkey. Requests are counted within discrete time windows; the counter resets when the window expires.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(client valkey.Client, cfg Config, opts ...capacitor.Option) capacitor.Capacitor

New creates a fixed-window Capacitor backed by the given Valkey client.

Types

type Config

type Config struct {
	Limit     int64         // maximum requests per window
	Window    time.Duration // window duration
	KeyPrefix string        // Valkey key prefix
	Timeout   time.Duration // per-operation Valkey timeout
}

Config defines the parameters for a fixed-window rate limiter.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults for general use.

Jump to

Keyboard shortcuts

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