func()

in pkg/stream/s3/s3_reader.go [81:110]


func (r *s3Reader) Read(p []byte) (n int, err error) {
	//Retry to handle dropped / spotty connections
	//AWS SDK retry strategy will only handle failed API calls, but not failed reads on the underlying stream
	//AWS SDK will also not retry on client errors, e.g. no network connection is present
	for i := r.config.NumRetries; i >= 0; i-- {
		n, err = r.read(p)

		//Retry on all request errors - worst case this adds 20 seconds to the deployment
		shouldRetry := false
		if awsErr, ok := err.(awserr.Error); ok {
			if awsErr.Code() == "RequestError" {
				shouldRetry = true
			}
		}

		if _, ok := err.(*ReadError); ok {
			shouldRetry = true
		}

		if shouldRetry {
			fmt.Printf("Error in s3Reader.Read: (%v). Retrying...\n", err)
			time.Sleep(r.config.RetryWait)
			continue
		}

		break
	}

	return
}