Add automatic retry policy for AI jobs
This commit is contained in:
22
internal/store/retry_policy.go
Normal file
22
internal/store/retry_policy.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type failRetryPolicy struct {
|
||||
Retryable bool
|
||||
Delay time.Duration
|
||||
}
|
||||
|
||||
func retryPolicyForError(errorCode string) failRetryPolicy {
|
||||
switch strings.TrimSpace(errorCode) {
|
||||
case "provider_unavailable", "model_unavailable", "timeout", "storage_error", "stale_worker":
|
||||
return failRetryPolicy{Retryable: true, Delay: 30 * time.Second}
|
||||
case "bad_response", "unknown":
|
||||
return failRetryPolicy{Retryable: true, Delay: 2 * time.Minute}
|
||||
default:
|
||||
return failRetryPolicy{}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user