Refactor gRPC adapter to use connection pool and improve error handling in product retrieval
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user