request_limiter

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateBindingRequest

type CreateBindingRequest struct {
	LimiterID  uint   `json:"limiter_id" binding:"required"`
	TargetType string `json:"target_type" binding:"required"`
	TargetID   uint   `json:"target_id"` // global 时为 0
	Enabled    bool   `json:"enabled"`
}

CreateBindingRequest 给某 limiter 加一条绑定。

type CreateRequest

type CreateRequest struct {
	Name         string `json:"name" binding:"required"`
	Enabled      bool   `json:"enabled"`
	Metric       string `json:"metric" binding:"required"`
	Capacity     int64  `json:"capacity"`
	WindowMs     int    `json:"window_ms"`
	KeyBy        string `json:"key_by" binding:"required"`
	ChannelScope string `json:"channel_scope"`
	Action       string `json:"action"`
	QueueSize    int    `json:"queue_size"`
	QueueTimeMs  int    `json:"queue_time_ms"`
	Priority     int    `json:"priority"`
}

CreateRequest 是新建一条 limiter 策略的入参(绑定另走 binding 接口)。

type Handler

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

func (*Handler) Create

func (*Handler) CreateBinding

func (*Handler) Delete

func (h *Handler) Delete(c *app.Context, req api.IDPathRequest) (api.StatusResponse, error)

func (*Handler) DeleteBinding

func (h *Handler) DeleteBinding(c *app.Context, req api.IDPathRequest) (api.StatusResponse, error)

func (*Handler) List

func (*Handler) ListBindings

func (h *Handler) ListBindings(c *app.Context, req ListBindingsRequest) ([]models.LimiterBinding, error)

func (*Handler) Update

func (h *Handler) Update(c *app.Context, req UpdateRequest) (models.RequestLimiter, error)

type ListBindingsRequest

type ListBindingsRequest struct {
	LimiterID string `form:"limiter_id" binding:"required"`
}

ListBindingsRequest 列出某 limiter 的绑定(limiter_id 必填)。

type ListRequest

type ListRequest struct {
	api.PaginationQuery
}

type UpdateRequest

type UpdateRequest struct {
	ID     string         `uri:"id" binding:"required"`
	Fields map[string]any `json:"-"`
}

func (*UpdateRequest) SetBodyMap

func (r *UpdateRequest) SetBodyMap(fields map[string]any)

Jump to

Keyboard shortcuts

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