common

package
v0.0.0-...-3fab846 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StoppedState = iota + 1
	RunningState
	StoppingState
)

Variables

View Source
var (
	InvalidPortRange = errors.New("Invalid port range")
	NoPortLeft       = errors.New("No free port left")
)
View Source
var (
	CantCompareInterface = errors.New("Can't compare interface")
	ErrFieldNotFound     = errors.New("Field not found")
	ErrFieldWrongType    = errors.New("Field has wrong type")
)
View Source
var (
	CaptureTypes = map[string]CaptureType{}
)

Functions

func CrossTypeCompare

func CrossTypeCompare(a interface{}, b interface{}) (int, error)

func CrossTypeEqual

func CrossTypeEqual(a interface{}, b interface{}) bool

func GetField

func GetField(obj map[string]interface{}, k string) (interface{}, error)

func IPToString

func IPToString(ip net.IP) string

func IPv6Supported

func IPv6Supported() bool

func IsCaptureAllowed

func IsCaptureAllowed(nodeType string) bool

func JsonDecode

func JsonDecode(r io.Reader, i interface{}) error

func MaxInt64

func MaxInt64(a, b int64) int64

func MinInt64

func MinInt64(a, b int64) int64

func Retry

func Retry(fnc func() error, try int, delay time.Duration) error

Retry tries to execute the given function until a success applying a delay between each try

func SetField

func SetField(obj map[string]interface{}, k string, v interface{}) bool

func ToFloat64

func ToFloat64(f interface{}) (float64, error)

func ToInt64

func ToInt64(i interface{}) (int64, error)

func UnixMillis

func UnixMillis(t time.Time) int64

Types

type CaptureType

type CaptureType struct {
	Allowed []string
	Default string
}

type Iterator

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

func NewIterator

func NewIterator(values ...int64) (it *Iterator)

func (*Iterator) Done

func (it *Iterator) Done() bool

func (*Iterator) Next

func (it *Iterator) Next() bool

type Metric

type Metric interface {
	GetFieldInt64(field string) (int64, error)
	Add(m Metric) Metric
}

type NetNSContext

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

func NewNetNsContext

func NewNetNsContext(path string) (*NetNSContext, error)

func (*NetNSContext) Close

func (n *NetNSContext) Close()

func (*NetNSContext) Quit

func (n *NetNSContext) Quit() error

type PortAllocator

type PortAllocator struct {
	sync.RWMutex
	MinPort int
	MaxPort int
	PortMap map[int]interface{}
}

func NewPortAllocator

func NewPortAllocator(min, max int) (*PortAllocator, error)

func (*PortAllocator) Allocate

func (p *PortAllocator) Allocate() (int, error)

func (*PortAllocator) Release

func (p *PortAllocator) Release(i int)

func (*PortAllocator) ReleaseAll

func (p *PortAllocator) ReleaseAll()

func (*PortAllocator) Set

func (p *PortAllocator) Set(i int, obj interface{})

type ServiceAddress

type ServiceAddress struct {
	Addr string
	Port int
}

func ServiceAddressFromString

func ServiceAddressFromString(addressPort string) (ServiceAddress, error)

type ServiceType

type ServiceType string
const (
	AnalyzerService ServiceType = "analyzer"
	AgentService    ServiceType = "agent"
)

func (ServiceType) String

func (st ServiceType) String() string

type SortOrder

type SortOrder string
const (
	SortAscending  SortOrder = "ASC"
	SortDescending SortOrder = "DESC"
)

type TimeSlice

type TimeSlice struct {
	Start int64 `json:"Start"`
	Last  int64 `json:"Last"`
}

func NewTimeSlice

func NewTimeSlice(s, l int64) *TimeSlice

type TimedMetric

type TimedMetric struct {
	TimeSlice
	Metric Metric
}

func (*TimedMetric) GetFieldInt64

func (tm *TimedMetric) GetFieldInt64(field string) (int64, error)

func (*TimedMetric) MarshalJSON

func (tm *TimedMetric) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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