leakybucket

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package leakybucket implements the Leaky Bucket rate limiting algorithm for traffic shaping.

Unlike Token Bucket which permits sudden request bursts, Leaky Bucket enforces a smooth, constant outflow rate. Requests that exceed the bucket capacity are immediately rejected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Strategy

type Strategy struct{}

Strategy implements the algorithm.Algorithm interface for Leaky Bucket.

func New

func New() *Strategy

New creates a new instance of the Leaky Bucket algorithm strategy.

func (*Strategy) EvaluateMemory

func (s *Strategy) EvaluateMemory(now time.Time, state *algorithm.State, limit int64, window time.Duration) algorithm.Result

EvaluateMemory evaluates the leaky bucket rate limit state synchronously in RAM. state.Tokens digunakan untuk merepresentasikan level "air" (water level) saat ini.

func (*Strategy) Name

func (s *Strategy) Name() string

Name returns the unique identifier of the algorithm strategy.

func (*Strategy) RedisScript

func (s *Strategy) RedisScript() string

RedisScript returns the atomic Lua script for Redis execution.

Jump to

Keyboard shortcuts

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