Added ignore event typs into notifications

Signed-off-by: elsanli(李楠) <elsanli@tencent.com>
This commit is contained in:
elsanli(李楠) 2018-01-18 18:26:54 +08:00
parent 5cb406d511
commit fc1d3647c6
7 changed files with 84 additions and 20 deletions

View file

@ -1,6 +1,7 @@
package notifications
import (
"github.com/docker/distribution/configuration"
"net/http"
"time"
)
@ -14,6 +15,7 @@ type EndpointConfig struct {
Backoff time.Duration
IgnoredMediaTypes []string
Transport *http.Transport `json:"-"`
Ignore configuration.Ignore
}
// defaults set any zero-valued fields to a reasonable default.
@ -63,7 +65,8 @@ func NewEndpoint(name, url string, config EndpointConfig) *Endpoint {
endpoint.Transport, endpoint.metrics.httpStatusListener())
endpoint.Sink = newRetryingSink(endpoint.Sink, endpoint.Threshold, endpoint.Backoff)
endpoint.Sink = newEventQueue(endpoint.Sink, endpoint.metrics.eventQueueListener())
endpoint.Sink = newIgnoredMediaTypesSink(endpoint.Sink, config.IgnoredMediaTypes)
mediaTypes := append(config.Ignore.MediaTypes, config.IgnoredMediaTypes...)
endpoint.Sink = newIgnoredSink(endpoint.Sink, mediaTypes, config.Ignore.Actions)
register(&endpoint)
return &endpoint