Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap GetRecords error in ScanShard #170

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (c *Consumer) ScanShard(ctx context.Context, shardID string, fn ScanFunc) e
c.logger.Log("[CONSUMER] get records error:", err.Error())

if !isRetriableError(err) {
return fmt.Errorf("get records error: %v", err.Error())
return fmt.Errorf("get records error: %w", err)
}

shardIterator, err = c.getShardIterator(ctx, c.streamName, shardID, lastSeqNum)
Expand Down
8 changes: 6 additions & 2 deletions consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ func TestScanShard_ShardIsClosed_WithShardClosedHandler(t *testing.T) {
}

func TestScanShard_GetRecordsError(t *testing.T) {
getRecordsError := &types.InvalidArgumentException{Message: aws.String("aws error message")}
var client = &kinesisClientMock{
getShardIteratorMock: func(ctx context.Context, params *kinesis.GetShardIteratorInput, optFns ...func(*kinesis.Options)) (*kinesis.GetShardIteratorOutput, error) {
return &kinesis.GetShardIteratorOutput{
Expand All @@ -406,8 +407,7 @@ func TestScanShard_GetRecordsError(t *testing.T) {
return &kinesis.GetRecordsOutput{
NextShardIterator: nil,
Records: nil,
},
&types.InvalidArgumentException{Message: aws.String("aws error message")}
}, getRecordsError
},
}

Expand All @@ -424,6 +424,10 @@ func TestScanShard_GetRecordsError(t *testing.T) {
if err.Error() != "get records error: InvalidArgumentException: aws error message" {
t.Fatalf("unexpected error: %v", err)
}

if !errors.Is(err, getRecordsError) {
t.Fatalf("unexpected error: %v", err)
}
}

type kinesisClientMock struct {
Expand Down