stats

package
v4.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ManagerType

func ManagerType() interface{}

ManagerType returns the type of Manager interface. Can be used to implement common.HasType.

Types

type Counter

type Counter interface {
	// Value is the current value of the counter.
	Value() int64
	// Set sets a new value to the counter, and returns the previous one.
	Set(int64) int64
	// Add adds a value to the current counter value, and returns the previous value.
	Add(int64) int64
}

Counter is the interface for stats counters.

func GetOrRegisterCounter

func GetOrRegisterCounter(m Manager, name string) (Counter, error)

GetOrRegisterCounter tries to get the StatCounter first. If not exist, it then tries to create a new counter.

type Manager

type Manager interface {
	features.Feature

	// RegisterCounter registers a new counter to the manager. The identifier string must not be emtpy, and unique among other counters.
	RegisterCounter(string) (Counter, error)
	// GetCounter returns a counter by its identifier.
	GetCounter(string) Counter
}

Manager is the interface for stats manager.

type NoopManager

type NoopManager struct{}

NoopManager is an implementation of Manager, which doesn't has actual functionalities.

func (NoopManager) Close

func (NoopManager) Close() error

Close implements common.Closable.

func (NoopManager) GetCounter

func (NoopManager) GetCounter(string) Counter

GetCounter implements Manager.

func (NoopManager) RegisterCounter

func (NoopManager) RegisterCounter(string) (Counter, error)

RegisterCounter implements Manager.

func (NoopManager) Start

func (NoopManager) Start() error

Start implements common.Runnable.

func (NoopManager) Type

func (NoopManager) Type() interface{}

Type implements common.HasType.

Jump to

Keyboard shortcuts

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