callbacks service draft
This commit is contained in:
27
api/edge/callbacks/internal/delivery/classifier.go
Normal file
27
api/edge/callbacks/internal/delivery/classifier.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package delivery
|
||||
|
||||
import "net/http"
|
||||
|
||||
type outcome string
|
||||
|
||||
const (
|
||||
outcomeDelivered outcome = "delivered"
|
||||
outcomeRetry outcome = "retry"
|
||||
outcomeFailed outcome = "failed"
|
||||
)
|
||||
|
||||
func classify(statusCode int, reqErr error) outcome {
|
||||
if reqErr != nil {
|
||||
return outcomeRetry
|
||||
}
|
||||
if statusCode >= http.StatusOK && statusCode < http.StatusMultipleChoices {
|
||||
return outcomeDelivered
|
||||
}
|
||||
if statusCode == http.StatusTooManyRequests || statusCode == http.StatusRequestTimeout {
|
||||
return outcomeRetry
|
||||
}
|
||||
if statusCode >= http.StatusInternalServerError {
|
||||
return outcomeRetry
|
||||
}
|
||||
return outcomeFailed
|
||||
}
|
||||
Reference in New Issue
Block a user