feat: create proxy layer, refactor caching layer to use defined structured values#3
Conversation
WalkthroughRefactors cache API to JSON-serialized typed responses, replaces sugared logger with structured zap.Logger, adds a Redis-backed HTTP proxy with cache-aware forwarding and a /clear endpoint, introduces server/proxy/origin config fields, implements a production main with graceful shutdown, and promotes several dependencies to direct requires. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Proxy as Proxy Handler (ServeProxy)
participant Cache as Redis Cache
participant Origin as Origin Server
Client->>Proxy: HTTP Request (method + URL)
Proxy->>Cache: Get(key)
alt Cache HIT
Cache-->>Proxy: (*CacheValue, true)
Proxy->>Proxy: WriteHeaders(state: "HIT")
Proxy-->>Client: Cached Response (status, headers, body)
else Cache MISS
Cache-->>Proxy: (nil, false)
Proxy->>Origin: Forward Request
Origin-->>Proxy: Response (Status, Headers, Body)
Proxy->>Cache: Put(CacheValue)
Proxy->>Proxy: WriteHeaders(state: "MISS")
Proxy-->>Client: Response + X-Cache: MISS
end
Note over Proxy,Cache: /clear endpoint calls Cache.Clear()
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Free 📒 Files selected for processing (2)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.