Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NdoleStudio/httpsms
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: NdoleStudio/httpsms
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: feat/api-rate-limiting
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 16 commits
  • 10 files changed
  • 2 contributors

Commits on Jun 30, 2026

  1. docs: add API rate limiting Phase 1 design spec

    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    97b1508 View commit details
    Browse the repository at this point in the history
  2. docs: add API rate limiting implementation plan

    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    672d3d9 View commit details
    Browse the repository at this point in the history
  3. 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>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    d282440 View commit details
    Browse the repository at this point in the history
  4. feat(events): add rate.limit.exceeded CloudEvent type

    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    0d671c2 View commit details
    Browse the repository at this point in the history
  5. 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>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    65ca2dd View commit details
    Browse the repository at this point in the history
  6. feat(middlewares): add rate limit middleware for tracking API usage

    Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    5cc7db3 View commit details
    Browse the repository at this point in the history
  7. 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>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    e2a75e6 View commit details
    Browse the repository at this point in the history
  8. 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>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    04ef44f View commit details
    Browse the repository at this point in the history
  9. 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>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    d2ece4f View commit details
    Browse the repository at this point in the history
  10. 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>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    df3368f View commit details
    Browse the repository at this point in the history
  11. 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>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    f15306e View commit details
    Browse the repository at this point in the history
  12. 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>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    3f8b8d1 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    f35d4cc View commit details
    Browse the repository at this point in the history
  14. 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>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    6b388e5 View commit details
    Browse the repository at this point in the history
  15. 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>
    AchoArnold and Copilot committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    214163e View commit details
    Browse the repository at this point in the history
  16. refactor: improve logging

    AchoArnold committed Jun 30, 2026
    Configuration menu
    Copy the full SHA
    736697c View commit details
    Browse the repository at this point in the history
Loading