Documentation
¶
Index ¶
- Constants
- Variables
- func AddTags(ms MapStr, tags []string) error
- func AutoGetAddress(addr string) string
- func ByteSize(bytes uint64) string
- func BytesToString(bs []byte) string
- func BytesToUint32(b []byte) (v uint32)
- func BytesToUint64(b []byte) (v uint64)
- func CheckInstanceLock(p string)
- func CheckProcessExists(pid int) bool
- func ClearInstanceLock()
- func ContainStr(s, substr string) bool
- func CopyFile(src, dst string) (w int64, err error)
- func CreateFile(dir string, name string) (string, error)
- func DeepCopy(value interface{}) interface{}
- func FileAppendContentWithByte(file string, content []byte) (int, error)
- func FileAppendNewLine(file string, content string) (int, error)
- func FileAppendNewLineWithByte(file string, content []byte) (int, error)
- func FileDelete(file string) error
- func FileExists(path string) bool
- func FileExtension(file string) string
- func FileGetContent(file string) ([]byte, error)
- func FileMTime(file string) (int64, error)
- func FilePutContent(file string, content string) (int, error)
- func FilePutContentWithByte(file string, content []byte) (int, error)
- func FileSize(file string) (int64, error)
- func FilterDirName(name string) bool
- func FilterSpecialChar(keyword string) string
- func FormatTime(date time.Time) string
- func FormatTimeWithLocalTZ(date time.Time) string
- func FormatTimeWithTZ(date time.Time) string
- func FromJSONBytes(b []byte, v interface{})
- func FromJson(str string, to interface{}) error
- func GetAvailablePort(ip string, port int) int
- func GetFieldValueByTagName(any interface{}, tagName string, tagValue string) string
- func GetHost(url string) string
- func GetIncrementID(bucket string) string
- func GetLocalZone() string
- func GetRootUrl(source *uri.URL) string
- func GetRuntimeErrorMessage(r runtime.Error) string
- func GetTypeName(any interface{}, lowercase bool) string
- func GetUUID() string
- func GetValidAddress(addr string) string
- func IntToString(num int) string
- func Invoke(any interface{}, name string, args ...interface{})
- func IsExist(path string) bool
- func IsFile(file string) bool
- func IsValidTLD(tld string) bool
- func JoinPath(filenames ...string) string
- func MergeFields(ms, fields MapStr, underRoot bool) error
- func MergeSpace(in string) (out string)
- func NoWordBreak(in string) string
- func PickRandomName() string
- func Post(url string, values url.Values) []byte
- func PrefixStr(s, substr string) bool
- func Rename(file string, to string) error
- func ReplaceByte(str []byte, old, new []byte) []byte
- func RestorePersistID(path string)
- func Sha1Hash(str string) string
- func SnapshotPersistID()
- func StringToUTF16(s string) []uint16
- func SubString(str string, begin, length int) (substr string)
- func SubStringWithSuffix(str string, length int, suffix string) string
- func SuffixStr(s, substr string) bool
- func TestListenPort(ip string, port int) bool
- func TestPort(port int) bool
- func ToBytes(s string) (uint64, error)
- func ToInt(str string) (int, error)
- func ToJSONBytes(v interface{}) []byte
- func ToJson(in interface{}, indent bool) string
- func ToLowercase(str []byte) []byte
- func ToMegabytes(s string) (uint64, error)
- func ToUppercase(str []byte) []byte
- func Uint32toBytes(b []byte, v uint32)
- func Uint64toBytes(b []byte, v uint64)
- func UnicodeIndex(str, substr string) int
- func UrlDecode(str string) string
- func UrlEncode(str string) string
- func XSSHandle(src string) string
- type EventMetadata
- type MapStr
- func (m MapStr) Clone() MapStr
- func (m MapStr) CopyFieldsTo(to MapStr, key string) error
- func (m MapStr) Delete(key string) error
- func (m MapStr) GetValue(key string) (interface{}, error)
- func (m MapStr) HasKey(key string) (bool, error)
- func (m MapStr) Put(key string, value interface{}) (interface{}, error)
- func (m MapStr) String() string
- func (m MapStr) StringToPrint() string
- func (m MapStr) Update(d MapStr)
- type Request
- type Result
- type StringSet
Constants ¶
const ( BYTE = 1.0 KILOBYTE = 1024 * BYTE MEGABYTE = 1024 * KILOBYTE GIGABYTE = 1024 * MEGABYTE TERABYTE = 1024 * GIGABYTE )
ByteSize unit definition
const ( FieldsKey = "fields" TagsKey = "tags" )
Event metadata constants. These keys are used to identify metadata stored in an event.
Variables ¶
var ( // ErrKeyNotFound indicates that the specified key was not found. ErrKeyNotFound = errors.New("key not found") )
Functions ¶
func AddTags ¶
AddTags appends a tag to the tags field of ms. If the tags field does not exist then it will be created. If the tags field exists and is not a []string then an error will be returned. It does not deduplicate the list of tags.
func AutoGetAddress ¶
AutoGetAddress get valid address to listen, if the specify port is not available, auto choose the next one
func ByteSize ¶
ByteSize returns a human-readable byte string of the form 10M, 12.5K, and so forth. The following units are available:
T: Terabyte G: Gigabyte M: Megabyte K: Kilobyte B: Byte
The unit that results in the smallest number greater than or equal to 1 is always chosen.
func BytesToString ¶ added in v0.9.0
func BytesToUint64 ¶
BytesToUint64 convert bytes to type uint64
func CheckInstanceLock ¶
func CheckInstanceLock(p string)
CheckInstanceLock make sure there is not a lock placed before check, and place a lock after check
func CheckProcessExists ¶ added in v0.9.0
CheckProcessExists check if the pid is running
func ContainStr ¶
func FileAppendContentWithByte ¶
FileAppendContentWithByte append bytes to the end of the file
func FileAppendNewLine ¶
FileAppendNewLine append new line to the end of the file
func FileAppendNewLineWithByte ¶
FileAppendNewLineWithByte append bytes and break line(\n) to the end of the file
func FileExtension ¶ added in v0.9.0
FileExtension extract file extension from file name
func FileGetContent ¶
FileGetContent get string from text file
func FilePutContent ¶
FilePutContent put string to file
func FilePutContentWithByte ¶
FilePutContentWithByte put string to file
func FilterDirName ¶
FilterDirName guess the file or directory is or contains Go source files.
func FilterSpecialChar ¶ added in v0.10.0
func FormatTime ¶
func FormatTimeWithLocalTZ ¶ added in v0.9.0
func FormatTimeWithTZ ¶ added in v0.9.0
func FromJSONBytes ¶ added in v0.10.0
func FromJSONBytes(b []byte, v interface{})
FromJSONBytes simply do json unmarshal
func GetAvailablePort ¶
GetAvailablePort get valid port to listen, if the specify port is not available, auto choose the next one
func GetFieldValueByTagName ¶ added in v0.9.0
GetFieldValueByTagName return the field value which field was tagged with this tagName, only support string field
func GetIncrementID ¶
GetIncrementID return incremented id in specify bucket
func GetRuntimeErrorMessage ¶
func GetTypeName ¶ added in v0.9.0
func GetValidAddress ¶
GetValidAddress get valid address, input: :8001 -> output: 127.0.0.1:8001
func IntToString ¶ added in v0.9.0
func Invoke ¶
func Invoke(any interface{}, name string, args ...interface{})
Invoke dynamic execute function via function name and parameters
func IsValidTLD ¶
IsValidTLD returns true if tld is a valid tld, eg: com
func MergeFields ¶
MergeFields merges the top-level keys and values in each source map (it does not perform a deep merge). If the same key exists in both, the value in fields takes precedence. If underRoot is true then the contents of the fields MapStr is merged with the value of the 'fields' key in ms.
An error is returned if underRoot is true and the value of ms.fields is not a MapStr.
func NoWordBreak ¶
func PickRandomName ¶ added in v0.9.0
func PickRandomName() string
PickRandomName return a random name
func ReplaceByte ¶ added in v0.9.0
TODO optimize performance ReplaceByte simply replace old bytes to new bytes, the two bytes should have same length
func RestorePersistID ¶ added in v0.9.0
func RestorePersistID(path string)
RestorePersistID will take the snapshot and restore to id seeds
func SnapshotPersistID ¶ added in v0.9.0
func SnapshotPersistID()
SnapshotPersistID will make a snapshot and persist id stats to disk
func StringToUTF16 ¶
func TestListenPort ¶
TestListenPort check availability of port with ip
func ToJSONBytes ¶ added in v0.10.0
func ToJSONBytes(v interface{}) []byte
ToJSONBytes convert interface to json with byte array
func ToLowercase ¶ added in v0.9.0
ToLowercase convert string bytes to lowercase
func ToMegabytes ¶
ToMegabytes parses a string formatted by ByteSize as megabytes.
func ToUppercase ¶ added in v0.9.0
ToUppercase convert string bytes to uppercase
func UnicodeIndex ¶
Types ¶
type EventMetadata ¶
type EventMetadata struct {
Fields MapStr
FieldsUnderRoot bool `config:"fields_under_root"`
Tags []string
}
EventMetadata contains fields and tags that can be added to an event via configuration.
type MapStr ¶
type MapStr map[string]interface{}
MapStr is a map[string]interface{} wrapper with utility methods for common map operations like converting to JSON.
func MapStrUnion ¶
MapStrUnion creates a new MapStr containing the union of the key-value pairs of the two maps. If the same key is present in both, the key-value pairs from dict2 overwrite the ones from dict1.
func (MapStr) Clone ¶
Clone returns a copy of the MapStr. It recursively makes copies of inner maps.
func (MapStr) CopyFieldsTo ¶
CopyFieldsTo copies the field specified by key to the given map. It will overwrite the key if it exists. An error is returned if the key does not exist in the source map.
func (MapStr) GetValue ¶
GetValue gets a value from the map. If the key does not exist then an error is returned.
func (MapStr) HasKey ¶
HasKey returns true if the key exist. If an error occurs then false is returned with a non-nil error.
func (MapStr) Put ¶
Put associates the specified value with the specified key. If the map previously contained a mapping for the key, the old value is replaced and returned. The key can be expressed in dot-notation (e.g. x.y) to put a value into a nested map.
If you need insert keys containing dots then you must use bracket notation to insert values (e.g. m[key] = value).
func (MapStr) StringToPrint ¶
StringToPrint returns the MapStr as pretty JSON.
type Request ¶ added in v0.9.0
type Request struct {
Method string
Url string
Cookie string
Proxy string
Body []byte
// contains filtered or unexported fields
}
func NewDeleteRequest ¶ added in v0.9.0
NewDeleteRequest issue a simple http delete request
func NewGetRequest ¶ added in v0.9.0
NewGetRequest issue a simple http get request
func NewPostRequest ¶ added in v0.9.0
NewPostRequest issue a simple http post request
func NewPutRequest ¶ added in v0.9.0
NewPutRequest issue a simple http put request
func (*Request) SetBasicAuth ¶ added in v0.9.0
SetBasicAuth set user and password for request
type Result ¶
type Result struct {
Host string
Url string
Headers map[string][]string
Body []byte
StatusCode int
Size uint64
}
Result is the http request result
func ExecuteRequest ¶ added in v0.9.0
ExecuteRequest issue a request
func HttpDelete ¶ added in v0.9.0
HttpDelete issue a simple http delete request
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package file copied from github.com/elastic/beats https://github.com/elastic/beats/blob/master/LICENSE Licensed under the Apache License, Version 2.0 (the "License");
|
Package file copied from github.com/elastic/beats https://github.com/elastic/beats/blob/master/LICENSE Licensed under the Apache License, Version 2.0 (the "License"); |