Documentation ¶
Overview ¶
eventmeter - generic system to subscribe to events and record their frequency.
Index ¶
- type DisconnectCallbackFunc
- type EventCallbackFunc
- type EventMeter
- func (em *EventMeter) GetMetric(query string) (*EventMetric, error)
- func (em *EventMeter) RegisterDisconnectCallback(f DisconnectCallbackFunc)
- func (em *EventMeter) RegisterLatencyCallback(f LatencyCallbackFunc)
- func (em *EventMeter) SetLogger(l log.Logger)
- func (em *EventMeter) Start() error
- func (em *EventMeter) Stop()
- func (em *EventMeter) String() string
- func (em *EventMeter) Subscribe(query string, cb EventCallbackFunc) error
- func (em *EventMeter) Unsubscribe(query string) error
- type EventMetric
- type EventUnmarshalFunc
- type LatencyCallbackFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DisconnectCallbackFunc ¶
type DisconnectCallbackFunc func()
DisconnectCallbackFunc is a closure to notify a consumer that the connection has died.
type EventCallbackFunc ¶
type EventCallbackFunc func(em *EventMetric, data interface{})
EventCallbackFunc is a closure to enable side effects from receiving an event.
type EventMeter ¶
type EventMeter struct {
// contains filtered or unexported fields
}
EventMeter tracks events, reports latency and disconnects.
func NewEventMeter ¶
func NewEventMeter(addr string, unmarshalEvent EventUnmarshalFunc) *EventMeter
func (*EventMeter) GetMetric ¶
func (em *EventMeter) GetMetric(query string) (*EventMetric, error)
GetMetric fills in the latest data for an query and return a copy.
func (*EventMeter) RegisterDisconnectCallback ¶
func (em *EventMeter) RegisterDisconnectCallback(f DisconnectCallbackFunc)
RegisterDisconnectCallback allows you to set disconnect callback.
func (*EventMeter) RegisterLatencyCallback ¶
func (em *EventMeter) RegisterLatencyCallback(f LatencyCallbackFunc)
RegisterLatencyCallback allows you to set latency callback.
func (*EventMeter) SetLogger ¶
func (em *EventMeter) SetLogger(l log.Logger)
SetLogger lets you set your own logger.
func (*EventMeter) String ¶
func (em *EventMeter) String() string
String returns a string representation of event meter.
func (*EventMeter) Subscribe ¶
func (em *EventMeter) Subscribe(query string, cb EventCallbackFunc) error
Subscribe for the given query. Callback function will be called upon receiving an event.
func (*EventMeter) Unsubscribe ¶
func (em *EventMeter) Unsubscribe(query string) error
Unsubscribe from the given query.
type EventMetric ¶
type EventMetric struct { ID string `json:"id"` Started time.Time `json:"start_time"` LastHeard time.Time `json:"last_heard"` MinDuration int64 `json:"min_duration"` MaxDuration int64 `json:"max_duration"` // filled in from the Meter Count int64 `json:"count"` Rate1 float64 `json:"rate_1" amino:"unsafe"` Rate5 float64 `json:"rate_5" amino:"unsafe"` Rate15 float64 `json:"rate_15" amino:"unsafe"` RateMean float64 `json:"rate_mean" amino:"unsafe"` // contains filtered or unexported fields }
EventMetric exposes metrics for an event.
func (*EventMetric) Copy ¶
func (metric *EventMetric) Copy() *EventMetric
type EventUnmarshalFunc ¶
EventUnmarshalFunc is a closure to get the query and data out of the raw JSON received over the RPC WebSocket.
type LatencyCallbackFunc ¶
type LatencyCallbackFunc func(meanLatencyNanoSeconds float64)
LatencyCallbackFunc is a closure to enable side effects from receiving a latency.