Refactor gRPC adapter to use connection pool and improve error handling in product retrieval

This commit is contained in:
2025-05-27 17:50:20 +03:00
parent b083cccc09
commit b48421e653
8 changed files with 44 additions and 40 deletions

View File

@@ -43,7 +43,6 @@ type RateLimitTransport struct {
}
func (t *RateLimitTransport) RoundTrip(req *http.Request) (*http.Response, error) {
fmt.Println(time.Now().Format("2006-01-02 15:04:05"))
ctx := req.Context()
clientId := req.Header.Get("Client-Id")
now := time.Now().UnixNano()
@@ -57,6 +56,7 @@ func (t *RateLimitTransport) RoundTrip(req *http.Request) (*http.Response, error
return nil, fmt.Errorf("failed to execute rate limit script: %w", err)
}
if waitTime > 0 {
fmt.Printf("Rate limit exceeded for client %s, waiting for %d nanoseconds\n", clientId, waitTime)
time.Sleep(time.Duration(waitTime))
}
return t.RoundTripper.RoundTrip(req)