Skip to content

Commit 2cd8a63

Browse files
committed
SCFF-5 handling a 429 response from Sumo (retry)
1 parent b437d4b commit 2cd8a63

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

sumoCFFirehose/sumoLogicAppender.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,24 @@ func (s *SumoLogicAppender) SendToSumo(logStringToSend string) {
138138
if err != nil {
139139
logging.Error.Printf("http.Do() error: %v\n", err)
140140
return
141+
} else if response.StatusCode == 429 { //that the endpoint needs some time and dropped the post sent
142+
logging.Trace.Println("Endpoint dropped the post send")
143+
logging.Trace.Println("Waiting for 300 ms to retry")
144+
time.Sleep(300 * time.Millisecond)
145+
responseRetry, errRetry := s.httpClient.Do(request)
146+
for responseRetry.StatusCode == 429 {
147+
logging.Trace.Println("Waiting for 300 ms to retry")
148+
time.Sleep(300 * time.Millisecond)
149+
responseRetry, errRetry = s.httpClient.Do(request)
150+
}
151+
if errRetry != nil {
152+
logging.Error.Printf("http.Do() error: %v\n", err)
153+
return
154+
} else {
155+
logging.Trace.Println("Post of logs successful")
156+
s.timerBetweenPost = time.Now()
157+
}
158+
141159
} else {
142160
logging.Trace.Println("Post of logs successful")
143161
s.timerBetweenPost = time.Now()

0 commit comments

Comments
 (0)