Documentation ¶
Index ¶
- Constants
- Variables
- func CombinedOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error)
- func Contains[T comparable](s []T, e T) bool
- func CutString(val string, maxLen int) string
- func DeepCopy(src *map[string]interface{}) *map[string]interface{}
- func DeleteAlarm(key string)
- func DoFuncWithTimeout(timeout time.Duration, workFunc func() error) error
- func GetHostName() string
- func GetIPAddress() string
- func GetTLSConfig(sslCert, sslKey, sslCA string, insecureSkipVerify bool) (*tls.Config, error)
- func GuessRegionByEndpoint(endPoint, defaultRegion string) string
- func InitFromEnvBool(key string, value *bool, defaultValue bool) error
- func InitFromEnvInt(key string, value *int, defaultValue int) error
- func InitFromEnvString(key string, value *string, defaultValue string) error
- func InterfaceToJSONString(val interface{}) (string, error)
- func InterfaceToString(val interface{}) (string, bool)
- func IsSafeString(str1, str2 string) bool
- func MinInt(a, b int) int
- func NewLogTagForPackID(prefix string, seqNum *int64) *protocol.LogTag
- func NewPackIDPrefix(text string) string
- func PathExists(path string) (bool, error)
- func RandomSleep(base time.Duration, precisionLose float64, shutdown <-chan struct{}) bool
- func RandomString(n int) string
- func ReadFirstBlock(line string) string
- func ReadLines(filename string) ([]string, error)
- func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error)
- func RegisterAlarm(key string, alarm *Alarm)
- func RegisterAlarmsSerializeToPb(logGroup *protocol.LogGroup)
- func RunTimeout(c *exec.Cmd, timeout time.Duration) error
- func SetNetworkIdentification(hostIP, hostname string)
- func Sleep(interval time.Duration, shutdown <-chan struct{}) bool
- func SnakeCase(in string) string
- func SplitPath(path string) (dir string, filename string)
- func StringDeepCopy(src string) string
- func StringPointer(s string) unsafe.Pointer
- func TryConvertLocalhost2RealIP(ip string) string
- func UniqueStrings(strSlices ...[]string) []string
- func WaitTimeout(c *exec.Cmd, timeout time.Duration) error
- func ZeroCopyBytesToString(b []byte) (s string)
- func ZeroCopyStringToBytes(s string) (b []byte)
- type Alarm
- type AlarmItem
- type TimeoutReader
Constants ¶
const ( InputCollectAlarm = "INPUT_COLLECT_ALARM" CategoryConfigAlarm = "CATEGORY_CONFIG_ALARM" )
const ( ShardHashTagKey = "__shardhash__" PackIDTagKey = "__pack_id__" )
const BufferSize = 4096
Variables ¶
var ( ErrCommandTimeout = errors.New("command time out") ErrNotImplemented = errors.New("not implemented yet") ErrInvalidEnvType = errors.New("invalid env type") )
var ErrReaderTimeout = errors.New("timeout")
var RegisterAlarms map[string]*Alarm
Functions ¶
func CombinedOutputTimeout ¶
CombinedOutputTimeout runs the given command with the given timeout and returns the combined output of stdout and stderr. If the command times out, it attempts to kill the process.
func Contains ¶
func Contains[T comparable](s []T, e T) bool
func DeleteAlarm ¶
func DeleteAlarm(key string)
func GetHostName ¶
func GetHostName() string
func GetIPAddress ¶
func GetIPAddress() string
func GetTLSConfig ¶
GetTLSConfig gets a tls.Config object from the given certs, key, and CA files. you must give the full path to the files. If all files are blank and InsecureSkipVerify=false, returns a nil pointer.
func GuessRegionByEndpoint ¶
GuessRegionByEndpoint guess region cn-hangzhou.log.aliyuncs.com cn-hangzhou-intranet.log.aliyuncs.com cn-hangzhou-vpc.log.aliyuncs.com cn-hangzhou-share.log.aliyuncs.com
func InitFromEnvString ¶
func InterfaceToJSONString ¶
func InterfaceToString ¶
func IsSafeString ¶
func NewPackIDPrefix ¶
func PathExists ¶
func RandomSleep ¶
return true if shutdown is signaled
func RandomString ¶
RandomString returns a random string of alpha-numeric characters
func ReadFirstBlock ¶
ReadFirstBlock read first \S+ from head of line
func ReadLines ¶
ReadLines reads contents from a file and splits them by new lines. A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).
func ReadLinesOffsetN ¶
ReadLinesOffsetN reads contents from file and splits them by new line. The offset tells at which line number to start. The count determines the number of lines to read (starting from offset): n >= 0: at most n lines n < 0: whole file
func RegisterAlarm ¶
func RunTimeout ¶
RunTimeout runs the given command with the given timeout. If the command times out, it attempts to kill the process.
func SetNetworkIdentification ¶
func SetNetworkIdentification(hostIP, hostname string)
SetNetworkIdentification updates return values of GetIPAddress and GetHostName. NOTE: It is not thread-safety, this is called by plugin_manager.LoadGlobalConfig only.
func SnakeCase ¶
SnakeCase converts the given string to snake case following the Golang format: acronyms are converted to lower-case and preceded by an underscore.
func StringDeepCopy ¶
StringDeepCopy returns a deep copy or src. Because we can not make sure the life cycle of string passed from C++, so we have to make a deep copy of them so that they are always valid in Go.
func StringPointer ¶
StringPointer returns the pointer of the given string. nolint:gosec
func UniqueStrings ¶
UniqueStrings Merge (append) slices and remove duplicate from them!
func WaitTimeout ¶
WaitTimeout waits for the given command to finish with a timeout. It assumes the command has already been started. If the command times out, it attempts to kill the process.
func ZeroCopyBytesToString ¶
func ZeroCopyStringToBytes ¶
Types ¶
type TimeoutReader ¶
type TimeoutReader struct {
// contains filtered or unexported fields
}
func NewTimeoutReader ¶
func NewTimeoutReader(r io.Reader, to time.Duration) *TimeoutReader