fix(GODT-2822): event loop behaviour on 429.

This commit is contained in:
Jakub
2023-07-31 13:52:39 +02:00
parent d7b71aceda
commit e26c7683d2
2 changed files with 10 additions and 1 deletions

View File

@ -379,3 +379,12 @@ func is429Error(err error) bool {
return false
}
func is429Or5XXError(err error) bool {
var apiErr *proton.APIError
if errors.As(err, &apiErr) {
return apiErr.Status == 429 || apiErr.Status >= 500
}
return false
}

View File

@ -778,7 +778,7 @@ func (user *User) doEventPoll(ctx context.Context) error {
}
// If the error is a server-side issue, return error to retry later.
if apiErr := new(proton.APIError); errors.As(err, &apiErr) && apiErr.Status >= 500 {
if is429Or5XXError(err) {
return fmt.Errorf("failed to handle event due to server error: %w", err)
}