-
-
Notifications
You must be signed in to change notification settings - Fork 433
Comparing changes
Open a pull request
base repository: NdoleStudio/httpsms
base: main
head repository: NdoleStudio/httpsms
compare: feat/api-rate-limiting
- 16 commits
- 10 files changed
- 2 contributors
Commits on Jun 30, 2026
-
docs: add API rate limiting Phase 1 design spec
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 97b1508 - Browse repository at this point
Copy the full SHA 97b1508View commit details -
docs: add API rate limiting implementation plan
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 672d3d9 - Browse repository at this point
Copy the full SHA 672d3d9View commit details -
feat(entities): add RateLimit() method to SubscriptionName
- Returns subscription.Limit() * 2 for daily API request budgets - Add 4 test cases covering Free, Pro, Ultra, and 200K subscriptions - RateLimit(): Free=400, Pro=10000, Ultra=20000, 200K=400000 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for d282440 - Browse repository at this point
Copy the full SHA d282440View commit details -
feat(events): add rate.limit.exceeded CloudEvent type
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 0d671c2 - Browse repository at this point
Copy the full SHA 0d671c2View commit details -
feat(services): implement RateLimitService with in-memory counters an…
…d Redis sync - Add RateLimitService with per-user API request tracking - Implement in-memory counters with 24h sliding windows - Add background flush to Redis every 30s with pipelining - Emit RateLimitExceeded events when limits are exceeded - Support graceful nil handling for tracer, logger, client, dispatcher - Add comprehensive tests for basic counting, weighted costs, limit enforcement, window expiry Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 65ca2dd - Browse repository at this point
Copy the full SHA 65ca2ddView commit details -
feat(middlewares): add rate limit middleware for tracking API usage
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 5cc7db3 - Browse repository at this point
Copy the full SHA 5cc7db3View commit details -
feat(di): wire rate limit service and middleware into DI container
- Add rateLimitService and redisClient fields to Container struct - Extract RedisClient() method for shared Redis client creation - Refactor Cache() to reuse RedisClient() singleton - Add RateLimitService() lazy singleton initialization - Register RateLimit middleware in App() after API key auth - Add RATE_LIMIT_ENABLED=false to .env.docker Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for e2a75e6 - Browse repository at this point
Copy the full SHA e2a75e6View commit details -
fix: add graceful shutdown for RateLimitService and handle Redis noti…
…fication errors - Add Container.Close() to flush rate limit counters on shutdown - Call defer container.Close() in main.go - Check and log errors from Redis notification flag persistence Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 04ef44f - Browse repository at this point
Copy the full SHA 04ef44fView commit details -
feat(services): add 1s Redis timeout, fail-open behavior, and shutdow…
…n logging - All Redis calls in RateLimitService use 1s context timeout - If Redis is slow/down, rate limiting continues in-memory (fail open) - Added logging to flush loop start/stop and graceful shutdown Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for d2ece4f - Browse repository at this point
Copy the full SHA d2ece4fView commit details -
refactor: use Fiber OnPreShutdown hook for RateLimitService cleanup
Replace defer container.Close() in main.go with app.Hooks().OnPreShutdown() which is the idiomatic Fiber v3 approach for graceful shutdown. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for df3368f - Browse repository at this point
Copy the full SHA df3368fView commit details -
refactor: remove nil checks for logger in RateLimitService, use OnPre…
…Shutdown - Logger is always injected via DI, nil checks are unnecessary - Use Fiber's app.Hooks().OnPreShutdown() for graceful shutdown - Remove defer container.Close() from main.go Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for f15306e - Browse repository at this point
Copy the full SHA f15306eView commit details -
refactor: gate rate limiting at container level, skip middleware enti…
…rely when disabled Move RATE_LIMIT_ENABLED check to container.go so the middleware, service, and Redis client are never initialized when rate limiting is disabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 3f8b8d1 - Browse repository at this point
Copy the full SHA 3f8b8d1View commit details -
Configuration menu - View commit details
-
Copy full SHA for f35d4cc - Browse repository at this point
Copy the full SHA f35d4ccView commit details -
perf: batch all Redis flush operations into a single pipeline call
Instead of creating a separate pipeline per user, all INCRBY+ExpireNX commands are batched into one pipeline.Exec() — one round-trip to Redis regardless of how many users have dirty counters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 6b388e5 - Browse repository at this point
Copy the full SHA 6b388e5View commit details -
refactor(api): use ctxLogger with span context in RateLimitService
Replace plain service.logger calls with ctxLogger (tracer-aware context logger) in flush, hydrate, and emitExceededEvent methods for trace correlation. Close/flushLoop keep plain logger since no request context. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 214163e - Browse repository at this point
Copy the full SHA 214163eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 736697c - Browse repository at this point
Copy the full SHA 736697cView commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff main...feat/api-rate-limiting