diff --git a/fanout.go b/fanout.go index 35864f9..c6c5e30 100644 --- a/fanout.go +++ b/fanout.go @@ -632,11 +632,14 @@ func isRetryableError(err error) bool { return false } + errMsg := strings.ToLower(err.Error()) + // Check specific error types that should be retried - if strings.Contains(err.Error(), "connection refused") || - strings.Contains(err.Error(), "timeout") || - strings.Contains(err.Error(), "connection reset") || - strings.Contains(err.Error(), "no such host") { + if strings.Contains(errMsg, "connection refused") || + strings.Contains(errMsg, "timeout") || + strings.Contains(errMsg, "deadline exceeded") || // Added this line + strings.Contains(errMsg, "connection reset") || + strings.Contains(errMsg, "no such host") { return true } diff --git a/fanout_test.go b/fanout_test.go index 8f711e7..eb0d1a3 100644 --- a/fanout_test.go +++ b/fanout_test.go @@ -153,9 +153,10 @@ func TestWriteJSON(t *testing.T) { expected: `{"key":"value"}`, }, { - name: "Response object", - data: Response{Target: "http://example.com", Status: 200, Body: "OK"}, - expected: `{"target":"http://example.com","status":200,"body":"OK"}`, + name: "Response object", + data: Response{Target: "http://example.com", Status: 200, Body: "OK"}, + // Updated to include latency and attempts fields + expected: `{"target":"http://example.com","status":200,"body":"OK","latency":0,"attempts":0}`, }, }