func (e *Endpoint) ReadMetrics(em *EndpointMetrics) {
	e.metrics.Lock()
	defer e.metrics.Unlock()
	*em = e.metrics.EndpointMetrics
	em.Statuses = make(map[string]int)
	for k, v := range e.metrics.Statuses {
		em.Statuses[k] = v
	}
}
ReadMetrics populates em with metrics from the endpoint.
package notifications
import (
	"net/http"
	"time"
)
type EndpointConfig struct {
	Headers           http.Header
	Timeout           time.Duration
	Threshold         int
	Backoff           time.Duration
	IgnoredMediaTypes []string
	Transport         *http.Transport
}
func (ec *EndpointConfig) defaults() {
	if ec.Timeout <= 0 {
		ec.Timeout = time.Second
	}
	if ec.Threshold <= 0 {
		ec.Threshold = 10
	}
	if ec.Backoff <= 0 {
		ec.Backoff = time.Second
	}
	if ec.Transport == nil {
		ec.Transport = http.DefaultTransport.(*http.Transport)
	}
}
type Endpoint struct {
	Sink
	url  string
	name string
	EndpointConfig
	metrics *safeMetrics
}
func NewEndpoint(name, url string, config EndpointConfig) *Endpoint {
	var endpoint Endpoint
	endpoint.name = name
	endpoint.url = url
	endpoint.EndpointConfig = config
	endpoint.defaults()
	endpoint.metrics = newSafeMetrics()
	endpoint.Sink = newHTTPSink(
		endpoint.url, endpoint.Timeout, endpoint.Headers,
		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)
	register(&endpoint)
	return &endpoint
}
func (e *Endpoint) Name() string {
	return e.name
}
func (e *Endpoint) URL() string {
	return e.url
}