diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-02-02 09:32:00 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-02-02 09:32:00 -0500 |
commit | 701d1ab638b23c24877fc41824add66232446676 (patch) | |
tree | ec120c88d38ac9d38d9eabdd3270b52bb6ac9d96 /vendor/github.com/minio/minio-go/api-notification.go | |
parent | ca3211bc04f6dea34e8168217182637d1419f998 (diff) | |
download | chat-701d1ab638b23c24877fc41824add66232446676.tar.gz chat-701d1ab638b23c24877fc41824add66232446676.tar.bz2 chat-701d1ab638b23c24877fc41824add66232446676.zip |
Updating server dependancies (#5249)
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) |