Documentation ¶
Index ¶
- type DummyHeartbeat
- type Handler
- type Heartbeat
- type HeartbeatStopper
- type Notifiable
- type Queue
- func (reporter *Queue) NotifyConnect(connected int)
- func (reporter *Queue) NotifyHeartbeat(when time.Time)
- func (reporter *Queue) RegisterEventHandler(typ Type, handler Handler)
- func (reporter *Queue) Shutdown()
- func (reporter *Queue) Start()
- func (reporter *Queue) UnregisterEventHandler(typ Type, handler Handler)
- type Type
- type UrlHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DummyHeartbeat ¶ added in v0.7.0
type DummyHeartbeat struct{}
type Heartbeat ¶ added in v0.7.0
type Heartbeat struct {
// contains filtered or unexported fields
}
func NewHeartbeat ¶ added in v0.7.0
func NewHeartbeat(interval time.Duration, target Notifiable) *Heartbeat
NewHeartbeat creates a new heartbeat ticker.
On each heartbeat, target.NotifyHeartbeat will be called with the current timestamp. Note that this happens asynchronously from a separate goroutine.
type HeartbeatStopper ¶ added in v0.7.0
type HeartbeatStopper interface {
Stop()
}
type Notifiable ¶
type Notifiable interface { // NotifyConnect reports new connections (if connected is positive) or // disconnects (if connected is negative). // // Connects and disconnects should be reported separately. NotifyConnect(connected int) // NotifyHeartbeat is called periodically when enabled, to allow sending // keepalive messages to a monitoring system NotifyHeartbeat(when time.Time) }
Notifiable defines the interface for a notification dispatcher.
Inidividual calls cause state changes, which may trigger events.
type Queue ¶ added in v0.10.0
type Queue struct {
// contains filtered or unexported fields
}
Queue encapsulates state for a connection load reporting callback.
The hit/miss pairs define a hysteresis range to avoid "flapping" reports when the number of connections changes quickly around a limit.
func NewQueue ¶ added in v0.10.0
NewQueue creates a new connection load report notifier.
limit specifies the reporting threshold.
func (*Queue) NotifyConnect ¶ added in v0.10.0
func (*Queue) NotifyHeartbeat ¶ added in v0.10.0
func (*Queue) RegisterEventHandler ¶ added in v0.10.0
func (*Queue) Shutdown ¶ added in v0.10.0
func (reporter *Queue) Shutdown()
Shutdown stops the load reporter and waits for completion.
You must not send any notifications after calling this method.
func (*Queue) Start ¶ added in v0.10.0
func (reporter *Queue) Start()
Start launches the reporting goroutine.
To stop the reporter, call Shutdown().
func (*Queue) UnregisterEventHandler ¶ added in v0.10.0
type UrlHandler ¶
type UrlHandler struct { // Url is the parsed URL Url *url.URL // contains filtered or unexported fields }
UrlHandler is an event handler that can send GET requests to a preconfigured HTTP URL.
func NewUrlHandler ¶
func NewUrlHandler(urly string, userauth *auth.UserAuthenticator) (*UrlHandler, error)
func (*UrlHandler) HandleEvent ¶
func (handler *UrlHandler) HandleEvent(typ Type, args ...interface{})