diff options
Diffstat (limited to 'vendor/github.com/minio/minio-go/api-notification.go')
-rw-r--r-- | vendor/github.com/minio/minio-go/api-notification.go | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/vendor/github.com/minio/minio-go/api-notification.go b/vendor/github.com/minio/minio-go/api-notification.go index 85e57805b..9c2a2ebd2 100644 --- a/vendor/github.com/minio/minio-go/api-notification.go +++ b/vendor/github.com/minio/minio-go/api-notification.go @@ -22,6 +22,9 @@ import ( "io" "net/http" "net/url" + "time" + + "github.com/minio/minio-go/pkg/s3utils" ) // GetBucketNotification - get bucket notification at a given path. @@ -135,7 +138,7 @@ func (c Client) ListenBucketNotification(bucketName, prefix, suffix string, even } // Check ARN partition to verify if listening bucket is supported - if isAmazonEndpoint(c.endpointURL) || isGoogleEndpoint(c.endpointURL) { + if s3utils.IsAmazonEndpoint(c.endpointURL) || s3utils.IsGoogleEndpoint(c.endpointURL) { notificationInfoCh <- NotificationInfo{ Err: ErrAPINotSupported("Listening bucket notification is specific only to `minio` partitions"), } @@ -143,7 +146,14 @@ func (c Client) ListenBucketNotification(bucketName, prefix, suffix string, even } // Continously run and listen on bucket notification. - for { + // Create a done channel to control 'ListObjects' go routine. + retryDoneCh := make(chan struct{}, 1) + + // Indicate to our routine to exit cleanly upon return. + defer close(retryDoneCh) + + // Wait on the jitter retry loop. + for range c.newRetryTimerContinous(time.Second, time.Second*30, MaxJitter, retryDoneCh) { urlValues := make(url.Values) urlValues.Set("prefix", prefix) urlValues.Set("suffix", suffix) @@ -155,10 +165,7 @@ func (c Client) ListenBucketNotification(bucketName, prefix, suffix string, even queryValues: urlValues, }) if err != nil { - notificationInfoCh <- NotificationInfo{ - Err: err, - } - return + continue } // Validate http response, upon error return quickly. @@ -180,10 +187,7 @@ func (c Client) ListenBucketNotification(bucketName, prefix, suffix string, even for bio.Scan() { var notificationInfo NotificationInfo if err = json.Unmarshal(bio.Bytes(), ¬ificationInfo); err != nil { - notificationInfoCh <- NotificationInfo{ - Err: err, - } - return + continue } // Send notifications on channel only if there are events received. if len(notificationInfo.Records) > 0 { @@ -200,12 +204,7 @@ func (c Client) ListenBucketNotification(bucketName, prefix, suffix string, even // and re-connect. if err == io.ErrUnexpectedEOF { resp.Body.Close() - continue } - notificationInfoCh <- NotificationInfo{ - Err: err, - } - return } } }(notificationInfoCh) |