model

package
v1.0.1 Latest Latest
Warning

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

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

Documentation

Overview

Package model defines the core configuration and policy types used by Seigen.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm string
const (
	TokenBucket          Algorithm = "token_bucket"
	LeakyBucket          Algorithm = "leaky_bucket"
	FixedWindow          Algorithm = "fixed_window"
	SlidingWindowLog     Algorithm = "sliding_window_log"
	SlidingWindowCounter Algorithm = "sliding_window_counter"
)

Supported rate-limiting algorithms.

type Config

type Config interface {
	// contains filtered or unexported methods
}

type Identifier

type Identifier string

type LeakyBucketConfig

type LeakyBucketConfig struct {
	Capacity     int           `json:"capacity"`
	LeakInterval time.Duration `json:"leak_interval"`
}

type LimiterConfig

type LimiterConfig struct {
	Algorithm Algorithm `json:"algorithm"`
	Config    Config    `json:"comfiguration"`
}

LimiterConfig defines the algorithm and configuration used by a limiter.

func (LimiterConfig) Equal

func (c LimiterConfig) Equal(other LimiterConfig) bool

func (LimiterConfig) Validate

func (c LimiterConfig) Validate() error

type Policy

type Policy struct {
	Identifier Identifier
	Limiter    LimiterConfig
}

Policy associates an identifier with a rate-limiting configuration.

func (Policy) Equal

func (p Policy) Equal(other Policy) bool

func (Policy) Validate

func (p Policy) Validate() error

type PolicyGroup

type PolicyGroup struct {
	Name    string
	Limiter LimiterConfig
}

PolicyGroup defines a shared rate-limiting configuration for multiple identifiers. Each member maintains independent runtime limiter state.

func (PolicyGroup) Validate

func (g PolicyGroup) Validate() error

type PolicyGroupMember

type PolicyGroupMember struct {
	GroupID    int64
	Identifier Identifier
}

PolicyGroupMember associates an identifier with a policy group.

func (PolicyGroupMember) Validate

func (m PolicyGroupMember) Validate() error

type TokenBucketConfig

type TokenBucketConfig struct {
	Capacity       int           `json:"capacity"`
	RefillInterval time.Duration `json:"refill_interval"`
	RefillAmount   int           `json:"refill_amount"`
}

type WindowConfig

type WindowConfig struct {
	Limit  int           `json:"limit"`
	Window time.Duration `json:"window"`
}

Jump to

Keyboard shortcuts

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