api: Notify events only if bucket notifications are set. (#2293)

While the existing code worked, it went to an entire cycle
of constructing event structure and end up not sending it.

Avoid this in the first place, but returning quickly if
notifications are not set on the bucket.
This commit is contained in:
Harshavardhana
2016-07-26 19:10:02 -07:00
committed by Anand Babu (AB) Periasamy
parent 3054b74260
commit 77248bd6e8
5 changed files with 67 additions and 15 deletions
+7 -1
View File
@@ -16,7 +16,10 @@
package main
import "encoding/xml"
import (
"encoding/xml"
"errors"
)
// Represents the criteria for the filter rule.
type filterRule struct {
@@ -68,6 +71,9 @@ type notificationConfig struct {
LambdaConfigurations []lambdaFuncConfig `xml:"CloudFunctionConfiguration"`
}
// Internal error used to signal notifications not set.
var errNoSuchNotifications = errors.New("The specified bucket does not have bucket notifications")
// EventName is AWS S3 event type:
// http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html
type EventName int