eventmeter

package
v0.25.1-br1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

eventmeter - generic system to subscribe to events and record their frequency.

Index

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) Start

func (em *EventMeter) Start() error

Start boots up event meter.

func (*EventMeter) Stop

func (em *EventMeter) Stop()

Stop stops event meter.

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

type EventUnmarshalFunc func(b json.RawMessage) (string, events.EventData, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL