use map for lookup of retriable errors
This commit is contained in:
parent
49b9bfa4e7
commit
1df9189517
1 changed files with 6 additions and 1 deletions
|
|
@ -151,7 +151,7 @@ func (c *Consumer) ScanShard(ctx context.Context, shardID string, fn ScanFunc) e
|
|||
c.logger.Log("[CONSUMER] get records error:", err.Error())
|
||||
|
||||
if awserr, ok := err.(awserr.Error); ok {
|
||||
if awserr.Code() != kinesis.ErrCodeExpiredIteratorException {
|
||||
if _, ok := retriableErrors[awserr.Code()]; !ok {
|
||||
return fmt.Errorf("get records error: %v", awserr.Message())
|
||||
}
|
||||
}
|
||||
|
|
@ -196,6 +196,11 @@ func (c *Consumer) ScanShard(ctx context.Context, shardID string, fn ScanFunc) e
|
|||
}
|
||||
}
|
||||
|
||||
var retriableErrors = map[string]struct{}{
|
||||
kinesis.ErrCodeExpiredIteratorException: struct{}{},
|
||||
kinesis.ErrCodeProvisionedThroughputExceededException: struct{}{},
|
||||
}
|
||||
|
||||
func isShardClosed(nextShardIterator, currentShardIterator *string) bool {
|
||||
return nextShardIterator == nil || currentShardIterator == nextShardIterator
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue