Files
fn_registry/functions/infra/rate_limiter_new.md
T
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

1.6 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports params output tested tests test_file_path file_path
rate_limiter_new function go infra 1.0.0 impure func RateLimiterNew(rate float64, burst int) *RateLimiter Crea un RateLimiter token-bucket in-memory vacio. rate son los tokens recargados por segundo, burst es la capacidad maxima del bucket. Valores <= 0 se sustituyen por 1 como minimo seguro.
rate_limit
http
middleware
token_bucket
infra
pendiente-usar
RateLimiter_go_infra
RateLimiter_go_infra
false error_go_core
name desc
rate tokens recargados por segundo (tasa sostenida, ej: 10 = 10 req/s)
name desc
burst capacidad maxima del bucket (rafaga maxima permitida en un instante, ej: 20)
puntero a RateLimiter inicializado con mapa vacio de clientes, listo para usar con RateLimiterCheck true
crea limiter con rate y burst configurados
valores cero se sustituyen por 1
el mapa de clientes empieza vacio
functions/infra/rate_limiter_new_test.go functions/infra/rate_limiter_new.go

Ejemplo

// 10 req/s sostenidos, hasta 20 en rafaga
rl := RateLimiterNew(10, 20)

// 1 req/s, sin rafaga
strict := RateLimiterNew(1, 1)

Notas

Funcion impura porque retorna un valor con estado mutable (mapa interno). No hace I/O ni network. La validacion de rate y burst evita panics por configuracion invalida (division por cero, buckets imposibles). Para iniciar el GC de entries inactivas usar RateLimiterCleanup.