ratelimit

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

ratelimit 包提供框架级会话限速插件。

Index

Constants

This section is empty.

Variables

View Source
var Plugin = absdk.Define(absdk.Spec[Config]{
	Manifest:      absdk.Manifest{Name: "ratelimit", Version: "1.0.2", Description: "会话限速中间件"},
	DefaultConfig: Config{Limit: 5, Window: "1m"},
	Setup: func(ctx *absdk.Context, cfg Config) error {
		window, err := cfg.window()
		if err != nil {
			return err
		}
		return ctx.UseGlobal(absdk.RateLimit(cfg.Limit, window))
	},
})

Functions

This section is empty.

Types

type Config

type Config struct {
	Limit  int    `yaml:"limit"`
	Window string `yaml:"window"`
}

func (Config) Validate

func (cfg Config) Validate() error

Jump to

Keyboard shortcuts

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