Skip to content

Releases: goceleris/celeris

v1.3.3

06 Apr 14:43
4b931fe

Choose a tag to compare

What's Changed

  • chore: bump sub-module celeris dependency v1.3.0 → v1.3.2 by @FumingPower3925 in #222
  • feat: v1.3.3 utility & serving middleware — pprof, swagger, static, rewrite, adapters by @FumingPower3925 in #223

Full Changelog: v1.3.2...v1.3.3

v1.3.2 — Resilience Middleware (Singleflight + Circuit Breaker)

06 Apr 00:16
b4b9b82

Choose a tag to compare

New Middleware

Package Description
singleflight Request coalescing — collapse N identical in-flight requests into 1 handler call, fan out the response
circuitbreaker Circuit breaker (3-state, sliding window error rate, 503 + Retry-After) with programmatic access

Security Fix

  • Singleflight cross-user data leakage: The default deduplication key includes Authorization and Cookie request headers, preventing one user's response (PII, session cookies) from being leaked to concurrent users hitting the same endpoint. Custom KeyFunc implementations must incorporate user identity for authenticated endpoints.

Highlights

Singleflight

  • Embedded singleflight group (no external dependencies)
  • Default key: method + path + sorted query + Authorization + Cookie (identity-aware)
  • x-singleflight: HIT header on coalesced responses
  • Deep-copy response body + headers for safe fan-out
  • Panic/error propagation from leader to all waiters
  • 23 tests, 98.8% coverage

Circuit Breaker

  • 3-state machine: Closed → Open → HalfOpen → Closed
  • Lock-free sliding window (10 atomic time buckets) — 0-alloc closed path
  • NewWithBreaker() for programmatic State(), Counts(), Reset()
  • Panic-aware: handler panics recorded as failures via defer/recover
  • Configurable: threshold, min requests, window size, cooldown, half-open max, custom IsError, OnStateChange callback
  • 26 tests, 96.2% coverage

Performance

Benchmark ns/op allocs
Singleflight Miss (leader) 215 5
Singleflight Skip 133 1
Circuit Breaker Closed 217 1
Circuit Breaker Open (fast reject) 128 0
Circuit Breaker Parallel (10 cores) 128 1

Under parallel load, celeris circuit breaker (128ns, lock-free atomics) outperforms sony/gobreaker (234ns, mutex-based) by 1.8x.

Other Fixes

  • Multi-value header replay: SetResponseHeaders preserves Set-Cookie and other multi-value headers for singleflight waiters
  • Leader error propagation: leader now returns the handler error (was discarding via FlushResponse)
  • Query param normalization: multi-value query params sorted within each key for deterministic deduplication
  • Circuit breaker validation: rejects negative CooldownPeriod, HalfOpenMax < 1, WindowSize < 10ms, MinRequests < 1
  • Window CAS retry loop: prevents lost count during bucket rotation
  • Breaker.Counts() for observability/Prometheus integration
  • Threshold doc corrected from (0,1) to (0,1]

Full Changelog

v1.3.1...v1.3.2

v1.3.1 — HTTP Transport Middleware

05 Apr 19:36
94d79de

Choose a tag to compare

New Middleware

Package Description
compress Response compression (zstd, brotli, gzip, deflate) with streaming support
etag Automatic ETag generation and conditional 304 Not Modified
proxy Trusted reverse proxy header extraction (client IP, scheme, host)
redirect URL redirect/rewrite (HTTPS, www, trailing slash) — 9 constructors
methodoverride HTTP method override via header, form field, or query param

Security Hardening

  • Context.Scheme() no longer trusts X-Forwarded-Proto from untrusted clients — only the proxy middleware (which validates against TrustedProxies) can set the scheme override
  • Proxy: X-Forwarded-Host validated against CRLF injection, path traversal, and 253-byte DNS limit; X-Real-IP validated with netip.ParseAddr
  • Method override: TargetMethods whitelist prevents overriding POST to CONNECT/TRACE/GET
  • Negotiate: q=0 correctly treated as "not acceptable" per RFC 9110, including wildcard exclusions
  • Redirect: only valid redirect codes (301/302/303/307/308) accepted
  • Compress: BREACH attack warning documented

Performance

Chain ns/op allocs
Standard API (reqid+recovery+cors+secure) 494 4
Production API (proxy+redirect+mo+reqid+recovery+cors+secure+rl+etag) 696 8
Full Stack (7 middleware + timeout) 1220 14
ETag 304 hit (1KB body) 302 2

Core Fixes

  • internal/negotiate: case-insensitive matching (RFC 9110), q=0 wildcard exclusion, alloc-free Parse scanner
  • Flaky TestAdaptiveAutoSingleWorker stabilized with H1 retry

Cross-Middleware Integration

  • Documented ordering: proxy→logger/ratelimit for correct ClientIP
  • CSRF ↔ MethodOverride security warning
  • Metrics/OTel response-size semantics with compress
  • Vary header convention (AddHeader not SetHeader)
  • Session + ETag cache interaction

Full Changelog

v1.3.0...v1.3.1

v1.3.0

05 Apr 16:29
d6dd587

Choose a tag to compare

What's Changed

  • arch: v1.3.0 — middleware in-tree, review-driven hardening, API additions by @FumingPower3925 in #174

Full Changelog: v1.2.4...v1.3.0

v1.2.4

04 Apr 19:49
2095aeb

Choose a tag to compare

What's Changed

Full Changelog: v1.2.3...v1.2.4

v1.2.3

04 Apr 15:17
88c92b2

Choose a tag to compare

What's Changed

Full Changelog: v1.2.2...v1.2.3

v1.2.2

01 Apr 11:59
00274dc

Choose a tag to compare

What's Changed

Full Changelog: v1.2.1...v1.2.2

v1.2.1

31 Mar 16:34
f107268

Choose a tag to compare

What's Changed

Full Changelog: v1.2.0...v1.2.1

v1.2.0

31 Mar 13:02
fd48182

Choose a tag to compare

What's Changed

Full Changelog: v1.1.0...v1.2.0

v1.1.0

30 Mar 21:16
39a7ce1

Choose a tag to compare

What's Changed

Full Changelog: v1.0.0...v1.1.0