ratelimit

package
v0.0.0-...-8d8ec1c Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package ratelimit - Token Bucket 기반의 Rate Limit 처리를 지원하는 패키지

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRouteLimited - Endpoint 기준 Rate Limit 제한인 경우의 오류
	ErrRouteLimited = errors.New("ERROR: Endpoint rate limit exceeded")
	// ErrClientLimited - Client 식별 기준 Rate Limit 제한인 경우의 오류
	ErrClientLimited = errors.New("ERROR: Endpoint(By Client) rate limit exceeded")
	// ErrProxyLimited - Rate Limit 제한인 경우의 오류
	ErrProxyLimited = core.NewWrappedError(503, "Proxy(Backend) rate limit exceeded", errors.New("ERROR: Proxy(Backend) rate limit exceeded"))
)

Functions

This section is empty.

Types

type ILimiter

type ILimiter interface {
	// Rate limit 초과 여부 검증
	Allow() bool
}

ILimiter - Rate limit 운영을 위한 인터페이스

type LimiterStore

type LimiterStore func(string) ILimiter

LimiterStore - 지정한 키에 해당하는 Limiter 정보를 검증하는 함수 구조

func NewLimitterStore

func NewLimitterStore(maxRate int, fillInterval int, fillCount int, backend backend.IBackend) LimiterStore

NewLimitterStore - Rate limit 정보 저장을 위한 Limiter Store 생성

func NewMemoryStore

func NewMemoryStore(maxRate int, fillInterval int, fillCount int) LimiterStore

NewMemoryStore - Memory를 기반으로 하는 LimiterStore 생성

type RateLimiter

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

RateLimiter - Rate limit 운영을 위한 Bucket Wrapper 구조

func NewLimiterWithRate

func NewLimiterWithRate(maxRate int, fillInterval int, fillCount int) RateLimiter

NewLimiterWithRate - 지정한 허용수를 기준으로 Rate Limiter 생성

func (RateLimiter) Allow

func (rl RateLimiter) Allow() bool

Allow - Rate Limit 처리를 위해 Bucket에서 Token 사용이 가능한지를 검증하고, 1개의 Token을 사용한다.

Directories

Path Synopsis
Package backend - Rate Limit 기능을 제공하는 저장소 패키지 Package backend - 문자열 Hash 처리 패키지 Package backend - Rate Limit 정보를 메모리에 관리하는 패키지 Package backend - MemoeryBackend에 대한 sharding 처리 패키지
Package backend - Rate Limit 기능을 제공하는 저장소 패키지 Package backend - 문자열 Hash 처리 패키지 Package backend - Rate Limit 정보를 메모리에 관리하는 패키지 Package backend - MemoeryBackend에 대한 sharding 처리 패키지
Package limiter - Rate Limit 처리용 TokenBucket 구현 패키지
Package limiter - Rate Limit 처리용 TokenBucket 구현 패키지
Package proxy - Backend 호출 구간에 대한 Rate Limit 적용 패키지
Package proxy - Backend 호출 구간에 대한 Rate Limit 적용 패키지
Package router - Endpoint 처리 구간에 Rate Limit 기능을 제공하는 Router 패키지
Package router - Endpoint 처리 구간에 Rate Limit 기능을 제공하는 Router 패키지
gin
Package gin - Gin Route (Endpoint) 처리 구간에 Rate Limit 기능을 제공하는 Gin Router 패키지
Package gin - Gin Route (Endpoint) 처리 구간에 Rate Limit 기능을 제공하는 Gin Router 패키지

Jump to

Keyboard shortcuts

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