From 1df918951767607b103190812e797454b279ed5a Mon Sep 17 00:00:00 2001 From: Harlow Ward Date: Tue, 30 Jul 2019 16:44:01 -0700 Subject: [PATCH] use map for lookup of retriable errors --- consumer.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/consumer.go b/consumer.go index eb28634..507076b 100644 --- a/consumer.go +++ b/consumer.go @@ -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 }