common

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StoppedState service stopped
	StoppedState = iota + 1
	// RunningState service running
	RunningState
	// StoppingState service stopping
	StoppingState
)

Variables

View Source
var (
	// ErrInvalidPortRange invalid port range
	ErrInvalidPortRange = errors.New("Invalid port range")
	// ErrNoPortLeft no port left in the range
	ErrNoPortLeft = errors.New("No free port left")
)
View Source
var (
	// ErrCantCompareInterface error can't compare inteface
	ErrCantCompareInterface = errors.New("Can't compare interface")
	// ErrFieldNotFound error field not found
	ErrFieldNotFound = errors.New("Field not found")
	// ErrFieldWrongType error field has wrong type
	ErrFieldWrongType = errors.New("Field has wrong type")
)
View Source
var (
	// CaptureTypes contain all registred capture type and associated probes
	CaptureTypes = map[string]CaptureType{}
)

Functions

func CrossTypeCompare

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

CrossTypeCompare compare 2 differents number types like Float64 vs Float32

func CrossTypeEqual

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

CrossTypeEqual compare 2 differents number types

func DelField added in v0.12.0

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

DelField detete a value in a tree based on dot key

func GetField added in v0.12.0

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

GetField retrieve a value from a tree from the dot key like "a.b.c.d"

func IPToString added in v0.9.0

func IPToString(ip net.IP) string

IPToString convert IPv4 or IPv6 to a string

func IPv6Supported added in v0.9.0

func IPv6Supported() bool

IPv6Supported returns true if the platform support IPv6

func IsCaptureAllowed

func IsCaptureAllowed(nodeType string) bool

IsCaptureAllowed returns true if the node capture type exist

func JSONDecode added in v0.12.0

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

JSONDecode wrapper to UseNumber during JSON decoding

func MaxInt64

func MaxInt64(a, b int64) int64

MaxInt64 returns the biggest value

func MinInt64

func MinInt64(a, b int64) int64

MinInt64 returns the lowest value

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 added in v0.12.0

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

SetField set a value in a tree based on dot key ("a.b.c.d" = "ok")

func SetupTLSClientConfig added in v0.12.0

func SetupTLSClientConfig(certPEM string, keyPEM string) *tls.Config

SetupTLSClientConfig creates a client X509 certificate from public and private key

func SetupTLSLoadCertificate added in v0.12.0

func SetupTLSLoadCertificate(certPEM string) *x509.CertPool

SetupTLSLoadCertificate creates a X509 certificate from file

func SetupTLSServerConfig added in v0.12.0

func SetupTLSServerConfig(certPEM string, keyPEM string) *tls.Config

SetupTLSServerConfig creates a server X509 certificate from public and private key

func ToFloat64 added in v0.9.0

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

ToFloat64 Convert all number like type to float64

func ToInt64 added in v0.9.0

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

ToInt64 Convert all number like type to int64

func UnixMillis added in v0.12.0

func UnixMillis(t time.Time) int64

UnixMillis returns the current time in miliseconds

Types

type CaptureType added in v0.9.0

type CaptureType struct {
	Allowed []string
	Default string
}

CaptureType describes a list of allowed and default captures probes

type Iterator added in v0.9.0

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

Iterator describes a int64 iterator

func NewIterator added in v0.9.0

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

NewIterator creates a new iterator based on (at, from, to) parameters

func (*Iterator) Done added in v0.9.0

func (it *Iterator) Done() bool

Done returns true when the Iterator is at the end or uninitialized properly

func (*Iterator) Next added in v0.9.0

func (it *Iterator) Next() bool

Next returns true if we can continue to iterate

type Metric added in v0.12.0

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

Metric defines accessors

type NetNSContext added in v0.9.0

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

NetNSContext describes a NameSpace Context switch API

func NewNetNsContext added in v0.9.0

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

NewNetNsContext creates a new NameSpace context base on path

func (*NetNSContext) Close added in v0.9.0

func (n *NetNSContext) Close()

Close the NameSpace

func (*NetNSContext) Quit added in v0.9.0

func (n *NetNSContext) Quit() error

Quit the NameSpace and go back to the original one

type PortAllocator added in v0.12.0

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

PortAllocator describes a threads safe port list that can be allocated

func NewPortAllocator added in v0.12.0

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

NewPortAllocator creates a new port allocator range

func (*PortAllocator) Allocate added in v0.12.0

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

Allocate returns a new unused port between min and max ports

func (*PortAllocator) Release added in v0.12.0

func (p *PortAllocator) Release(i int) error

Release a port

func (*PortAllocator) ReleaseAll added in v0.12.0

func (p *PortAllocator) ReleaseAll()

ReleaseAll ports

func (*PortAllocator) Set added in v0.12.0

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

Set associate an object to the port map

type RawSocket added in v0.12.0

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

RawSocket describes a raw socket C implemenation

func NewRawSocket added in v0.12.0

func NewRawSocket(ifName string) (*RawSocket, error)

NewRawSocket creates a raw socket for the network interface ifName

func NewRawSocketInNs added in v0.12.0

func NewRawSocketInNs(nsPath string, ifName string) (*RawSocket, error)

NewRawSocketInNs create/open a socket in the namespace nsPath for the network interface ifName

func (*RawSocket) Close added in v0.12.0

func (s *RawSocket) Close() error

Close the file descriptor

func (*RawSocket) GetFd added in v0.12.0

func (s *RawSocket) GetFd() int

GetFd returns the file descriptor

type ServiceAddress added in v0.12.0

type ServiceAddress struct {
	Addr string
	Port int
}

ServiceAddress describes the service listening address and port

func ServiceAddressFromString added in v0.12.0

func ServiceAddressFromString(addressPort string) (ServiceAddress, error)

ServiceAddressFromString returns a service address from a string, could be IPv4 or IPv6

type ServiceType added in v0.12.0

type ServiceType string

ServiceType describes the service type (analyzer or agent)

const (
	// AnalyzerService analyzer
	AnalyzerService ServiceType = "analyzer"
	// AgentService agent
	AgentService ServiceType = "agent"
)

func (ServiceType) String added in v0.12.0

func (st ServiceType) String() string

type SortOrder added in v0.12.0

type SortOrder string

SortOrder describes ascending or descending order

const (
	// SortAscending sorting order
	SortAscending SortOrder = "ASC"
	// SortDescending sorting order
	SortDescending SortOrder = "DESC"
)

type TimeSlice added in v0.12.0

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

TimeSlice defines a time boudary values

func NewTimeSlice added in v0.12.0

func NewTimeSlice(s, l int64) *TimeSlice

NewTimeSlice creates a new TimeSlice based on Start and Last

type TimedMetric added in v0.12.0

type TimedMetric struct {
	TimeSlice
	Metric Metric
}

TimedMetric defines Metric during a time slice

func (*TimedMetric) GetFieldInt64 added in v0.12.0

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

GetFieldInt64 returns the field value

func (*TimedMetric) MarshalJSON added in v0.12.0

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

MarshalJSON serialized a TimedMetric in JSON

Source Files

  • capture.go
  • common.go
  • iterator.go
  • ns.go
  • port_allocator.go
  • service.go
  • socket.go
  • tls.go
  • types.go

Jump to

Keyboard shortcuts

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