events

package
v0.1.0-beta9 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeTask

func MergeTask(dst, src *Event, static map[string]string) func()

MergeTask creates a task that merges src to dst filling missing labels with values from static

Types

type Counter

type Counter struct {
	Count  int64    `json:"n"`
	Values []string `json:"v,omitempty"`
}

Counter counts events labeled by values

func (*Counter) Match

func (c *Counter) Match(values []string) bool

Match checks if values match counter's own values

type CounterSlice

type CounterSlice []Counter

CounterSlice is a slice of counters

func (CounterSlice) FilterZero

func (s CounterSlice) FilterZero() CounterSlice

FilterZero filters out empty counters in-place

func (CounterSlice) Reset

func (s CounterSlice) Reset() CounterSlice

Reset resets a snapshot

func (CounterSlice) Zero

func (s CounterSlice) Zero()

Zero resets all counters to zero count

type Counters

type Counters struct {
	// contains filtered or unexported fields
}

Counters is an index of counters safe for councurrent use

func NewCounters

func NewCounters(size int) *Counters

NewCounters creates a new counter index of size capacity

func (*Counters) Add

func (cs *Counters) Add(n int64, values ...string) int64

Add adds n to a specific counter

func (*Counters) Flush

func (cs *Counters) Flush(s []Counter) []Counter

func (*Counters) Len

func (cs *Counters) Len() (n int)

Len returns the number of counters in an Event

func (*Counters) Merge

func (cs *Counters) Merge(s CounterSlice)

Merge adds all counters from a CounterSlice

func (*Counters) Pack

func (cs *Counters) Pack()

Pack packs the counter index dropping zero counters

type Event

type Event struct {
	Name   string   `json:"name"`
	Labels []string `json:"labels"`
	*Counters
}

Event stores counters for an event

func NewEvent

func NewEvent(name string, labels ...string) *Event

NewEvent creates a new Event using the specified labels

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func (*Registry) Events

func (r *Registry) Events() map[string]*Event

func (*Registry) Get

func (r *Registry) Get(name string) (e *Event)

func (*Registry) Register

func (r *Registry) Register(event *Event) bool

type UnsafeCounters

type UnsafeCounters struct {
	// contains filtered or unexported fields
}

UnsafeCounters is an index of counters not safe for concurrent use

func (*UnsafeCounters) Add

func (cs *UnsafeCounters) Add(n int64, values ...string) int64

Add increments a counter matching values by n

func (*UnsafeCounters) Flush

Flush appends all counters to a snapshot and resets them to zero

func (*UnsafeCounters) Get

func (cs *UnsafeCounters) Get(i int) *Counter

Get returns the counter at index i

func (*UnsafeCounters) Len

func (cs *UnsafeCounters) Len() int

Len returns the number of counters in an Event

func (*UnsafeCounters) Pack

func (cs *UnsafeCounters) Pack()

Pack packs the counter index dropping zero counters

Jump to

Keyboard shortcuts

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