The previous pipeline model required a lot of setup and abstracted away the processing of records. By passing a HandlerFunc to the consumer we keep the business logic of processing of records closer to the use of the consumer. * Add refactoring note and SHA to README
33 lines
1.1 KiB
Text
33 lines
1.1 KiB
Text
package connector
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"testing"
|
|
|
|
"github.com/bmizerany/assert"
|
|
"github.com/lib/pq"
|
|
"github.com/sendgridlabs/go-kinesis"
|
|
)
|
|
|
|
func Test_isRecoverableError(t *testing.T) {
|
|
testCases := []struct {
|
|
err error
|
|
isRecoverable bool
|
|
}{
|
|
{err: &kinesis.Error{Code: "ProvisionedThroughputExceededException"}, isRecoverable: true},
|
|
{err: &kinesis.Error{Code: "Throttling"}, isRecoverable: true},
|
|
{err: &kinesis.Error{Code: "ServiceUnavailable"}, isRecoverable: true},
|
|
{err: &kinesis.Error{Code: "ExpiredIteratorException"}, isRecoverable: false},
|
|
{err: &net.OpError{Err: fmt.Errorf("connection reset by peer")}, isRecoverable: true},
|
|
{err: &net.OpError{Err: fmt.Errorf("unexpected error")}, isRecoverable: false},
|
|
{err: fmt.Errorf("an arbitrary error"), isRecoverable: false},
|
|
{err: pq.Error{Message: "The specified S3 prefix 'somefilethatismissing' does not exist"}, isRecoverable: true},
|
|
{err: pq.Error{Message: "Some other pq error"}, isRecoverable: false},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
isRecoverable := isRecoverableError(tc.err)
|
|
assert.Equal(t, isRecoverable, tc.isRecoverable)
|
|
}
|
|
}
|