util

package
v0.0.0-...-1d9613f Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) error

CopyFile atomically copies file path `src“ to file path `dst`.

func CopyFileAll

func CopyFileAll(src, dst string) error

CopyFileAll calls CopyFile, but will create necessary directories for `dst`.

func CreateHTTPTransport

func CreateHTTPTransport() *http.Transport

CreateHTTPTransport creates an *http.Transport for use in the agent

func EnsureParentDirsExist

func EnsureParentDirsExist(p string) error

EnsureParentDirsExist makes a path immediately available for writing by creating the necessary parent directories.

func Fqdn

func Fqdn(hostname string) string

Fqdn returns the FQDN for the host if any

func GetHostname

func GetHostname() (string, error)

GetHostname retrieve the host name for the Agent, trying to query these environments/api, in order: * GCE * Docker * kubernetes * os * EC2

func GetJSONSerializableMap

func GetJSONSerializableMap(m interface{}) interface{}

GetJSONSerializableMap returns a JSON serializable map from a raw map

func GetProxyTransportFunc

func GetProxyTransportFunc(p *config.Proxy) func(*http.Request) (*url.URL, error)

GetProxyTransportFunc return a proxy function for a http.Transport that would return the right proxy depending on the configuration.

func HTTPHeaders

func HTTPHeaders() map[string]string

HTTPHeaders returns a http headers including various basic information (User-Agent, Content-Type...).

func ValidHostname

func ValidHostname(hostname string) error

ValidHostname determines whether the passed string is a valid hostname. In case it's not, the returned error contains the details of the failure.

Types

type BiMap

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

BiMap provides a bidirectional map of keys and values.

func NewBiMap

func NewBiMap(k, v interface{}) *BiMap

NewBiMap instantiates BiMap

func (*BiMap) AddKV

func (b *BiMap) AddKV(k, v interface{}) error

AddKV adds value `v` to map the map indexed with key `k`.

func (*BiMap) GetKV

func (b *BiMap) GetKV(key interface{}) (interface{}, error)

GetKV gets value provided the key.

func (*BiMap) GetKVBimap

func (b *BiMap) GetKVBimap(key interface{}) (interface{}, error)

GetKVBimap looks for the provided key both for keys and values in the map.

The first occurrence will be returned.

func (*BiMap) GetKVReverse

func (b *BiMap) GetKVReverse(key interface{}) (interface{}, error)

GetKVReverse gets key provided the value.

func (*BiMap) Keys

func (b *BiMap) Keys() []interface{}

Keys returns a slice with all keys in the map.

func (*BiMap) Values

func (b *BiMap) Values() []interface{}

Values returns a slice with all values in the map.

type NamedPipe

type NamedPipe interface {
	Open() error
	Ready() bool
	Read(b []byte) (int, error)
	Write(b []byte) (int, error)
	Close() error
}

NamedPipe interface to NamedPipes (multi-platform)

func GetPipe

func GetPipe(path string) (NamedPipe, error)

GetPipe returns a UnixPipe to path

type Stat

type Stat struct {
	Val int64
	Ts  time.Time
}

Stat type includes a statted value and its timestamp.

type Stats

type Stats struct {
	Aggregated chan Stat
	// contains filtered or unexported fields
}

Stats type structure enabling statting facilities.

func NewStats

func NewStats(sz uint32) (*Stats, error)

NewStats constructor for Stats

func (*Stats) Process

func (s *Stats) Process()

Process call to start processing statistics

func (*Stats) StatEvent

func (s *Stats) StatEvent(v int64)

StatEvent aggregates an event with value v

func (*Stats) Stop

func (s *Stats) Stop()

Stop call to stop processing statistics

type UnixNamedPipe

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

UnixNamedPipe unix abstraction to named pipes

func NewUnixNamedPipe

func NewUnixNamedPipe(path string) (*UnixNamedPipe, error)

NewUnixNamedPipe UnixNamedPipe constructor

func (*UnixNamedPipe) Close

func (p *UnixNamedPipe) Close() error

Close the underlying named pipe

func (*UnixNamedPipe) Open

func (p *UnixNamedPipe) Open() error

Open opens named pipe - will create it if doesn't exist

func (*UnixNamedPipe) Read

func (p *UnixNamedPipe) Read(b []byte) (int, error)

Read from the pipe

func (*UnixNamedPipe) Ready

func (p *UnixNamedPipe) Ready() bool

Ready is the pipe ready to read/write?

func (*UnixNamedPipe) Write

func (p *UnixNamedPipe) Write(b []byte) (int, error)

Write to the pipe

Directories

Path Synopsis
Package ecs provides metadata collection when the Agent runs on the ECS platform
Package ecs provides metadata collection when the Agent runs on the ECS platform
Package executable provides information on the executable that started the process
Package executable provides information on the executable that started the process

Jump to

Keyboard shortcuts

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