add more recoverable errors
This commit is contained in:
parent
969ba18824
commit
a028ee862f
1 changed files with 34 additions and 5 deletions
39
pipeline.go
39
pipeline.go
|
|
@ -3,6 +3,7 @@ package connector
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
|
"net"
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -25,8 +26,34 @@ type Pipeline struct {
|
||||||
CheckpointFilteredRecords bool
|
CheckpointFilteredRecords bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var pipelineRecoverableErrorCodes = map[string]bool{
|
type pipelineIsRecoverableErrorFunc func(error) bool
|
||||||
"ProvisionedThroughputExceededException": true,
|
|
||||||
|
func pipelineKinesisIsRecoverableError(err error) bool {
|
||||||
|
recoverableErrorCodes := map[string]bool{
|
||||||
|
"ProvisionedThroughputExceededException": true,
|
||||||
|
}
|
||||||
|
r := false
|
||||||
|
cErr, ok := err.(*kinesis.Error)
|
||||||
|
if ok && recoverableErrorCodes[cErr.Code] == true {
|
||||||
|
r = true
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func pipelineNetIsRecoverableError(err error) bool {
|
||||||
|
recoverableErrors := map[string]bool{
|
||||||
|
"connection reset by peer": true,
|
||||||
|
}
|
||||||
|
r := false
|
||||||
|
cErr, ok := err.(*net.OpError)
|
||||||
|
if ok && recoverableErrors[cErr.Err.Error()] == true {
|
||||||
|
r = true
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
var pipelineIsRecoverableErrors = []pipelineIsRecoverableErrorFunc{
|
||||||
|
pipelineKinesisIsRecoverableError, pipelineNetIsRecoverableError,
|
||||||
}
|
}
|
||||||
|
|
||||||
// this determines whether the error is recoverable
|
// this determines whether the error is recoverable
|
||||||
|
|
@ -35,9 +62,11 @@ func (p Pipeline) isRecoverableError(err error) bool {
|
||||||
|
|
||||||
log.Printf("isRecoverableError, type %s, value (+%v)\n", reflect.TypeOf(err).String(), err)
|
log.Printf("isRecoverableError, type %s, value (+%v)\n", reflect.TypeOf(err).String(), err)
|
||||||
|
|
||||||
cErr, ok := err.(*kinesis.Error)
|
for _, errF := range pipelineIsRecoverableErrors {
|
||||||
if ok && pipelineRecoverableErrorCodes[cErr.Code] == true {
|
r = errF(err)
|
||||||
r = true
|
if r {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue