-
Notifications
You must be signed in to change notification settings - Fork 50
/
retry.go
30 lines (24 loc) · 869 Bytes
/
retry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package kinesis
import (
"errors"
"time"
"github.com/aws/aws-sdk-go-v2/service/kinesis/types"
gosoAws "github.com/justtrackio/gosoline/pkg/cloud/aws"
)
type BackoffDelayer struct {
*gosoAws.BackoffDelayer
readProvisionedThroughputDelay time.Duration
}
func NewBackoffDelayer(initialInterval time.Duration, maxInterval time.Duration, readProvisionedThroughputDelay time.Duration) *BackoffDelayer {
return &BackoffDelayer{
BackoffDelayer: gosoAws.NewBackoffDelayer(initialInterval, maxInterval),
readProvisionedThroughputDelay: readProvisionedThroughputDelay,
}
}
func (d *BackoffDelayer) BackoffDelay(attempt int, err error) (time.Duration, error) {
var pte *types.ProvisionedThroughputExceededException
if errors.As(err, &pte) {
return d.readProvisionedThroughputDelay, nil
}
return d.BackoffDelayer.BackoffDelay(attempt, err)
}