Documentation ¶
Index ¶
- func BoolToInt64(b bool) int64
- func BuildPeriod(interval int64) int64
- func BuildTagsKey(tags map[string]string) string
- func ConvertStringSliceToHashSet(a []string) map[string]struct{}
- func CopyConn(ctx context.Context, conn1 io.ReadWriter, conn2 io.ReadWriter, ...) error
- func CopyFileUsingCp(ctx context.Context, src, dst string) error
- func CopyStringMap(m map[string]string) map[string]string
- func CopyStringMapCap(m map[string]string, cap int) map[string]string
- func CopyStringSlice(src []string) []string
- func CreateDirIfNotExists(dir string, perm os.FileMode) error
- func CreateHttpClientWithDialContext(dial func(ctx context.Context, network, addr string) (net.Conn, error)) (*http.Transport, *http.Client, error)
- func CurrentMS() int64
- func DeepCopyString(s string) string
- func DeepCopyStringSlice(a []string) []string
- func FirstNotEmpty(strs ...string) string
- func GetEnvOrDefault(name, defaultValue string) string
- func GetHostname() string
- func GetLocalIp() string
- func GetLocalTimezone() string
- func GobDecode(b []byte, obj interface{}) error
- func GobEncode(obj interface{}) ([]byte, error)
- func IsContextDone(ctx context.Context) bool
- func IsContextNotDone(ctx context.Context) bool
- func IsLinux() bool
- func IsNotImplemented(err error) bool
- func MaybeCloseRead(conn interface{}) error
- func MaybeCloseWrite(conn interface{}) error
- func MaybeIOClose(i interface{}) error
- func MaybeSetDeadline(i interface{}, d time.Time) error
- func MergeStringMapTo(a map[string]string, to map[string]string, override bool) map[string]string
- func NewClientTLSFromBase64(certBase64, serverNameOverride string) (credentials.TransportCredentials, error)
- func NextDelay(interval time.Duration) time.Duration
- func NextDelayFrom(now time.Time, interval time.Duration) time.Duration
- func OpenFileReadonly(file string) (*os.File, error)
- func ParseDuration(d interface{}) (time.Duration, error)
- func ParseDurationDefault(s string, d time.Duration) time.Duration
- func ParseStringSliceEnvToMap(envs []string) map[string]string
- func RandBetween(min, max int) int
- func RandBetween64(min, max int64) int64
- func ReplaceHost(hostport string, host string) string
- func ReplaceHostToLocalhost(hostport string) string
- func ReverseStringSlice(a []string)
- func SetLocalIp(ip string)
- func String(b []byte) string
- func StringSliceContains(elems []string, elem string) bool
- func StringSliceFind(elems []string, elem string) int
- func SubBytesMax(bs []byte, max int) []byte
- func SubContextTimeout(ctx context.Context, timeout time.Duration, callback func(context.Context))
- func SubContextTimeoutE(ctx context.Context, timeout time.Duration, ...) error
- func SubstringMax(s string, n int) string
- func SyncMapSize(m *sync.Map) int
- func TimeTruncateToDay(t time.Time) time.Time
- func ToJsonBuffer(v interface{}) *bytes.Buffer
- func ToJsonBufferE(v interface{}) (*bytes.Buffer, error)
- func ToJsonBytes(v interface{}) []byte
- func ToJsonString(v interface{}) string
- func ToMS(t time.Time) int64
- func TransformStringSlice(strs []string, transformer func(string) string) []string
- func ZeroCopyStringToBytes(s string) (b []byte)
- type AlignedTimer
- type DnsCacheHelper
- type ReadWriterConn
- func (r *ReadWriterConn) Close() error
- func (r *ReadWriterConn) CloseRead() error
- func (r *ReadWriterConn) CloseWrite() error
- func (r *ReadWriterConn) LocalAddr() net.Addr
- func (r *ReadWriterConn) RemoteAddr() net.Addr
- func (r *ReadWriterConn) SetDeadline(t time.Time) error
- func (r *ReadWriterConn) SetReadDeadline(t time.Time) error
- func (r *ReadWriterConn) SetWriteDeadline(t time.Time) error
- type ReaderCloserFunc
- type ReaderReadHook
- type Signal
- type SortStringsByLength
- type StopSignal
- type WriterWriteHook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildPeriod ¶
func BuildTagsKey ¶
BuildTagsKey build string from tags "key1=value1 key2=value2 key3=value3" key1 ... keyn is sorted
func CopyConn ¶
func CopyConn(ctx context.Context, conn1 io.ReadWriter, conn2 io.ReadWriter, timeout time.Duration) error
func CopyFileUsingCp ¶
CopyFileUsingCp copies file using cp binary (in agent container)
func CopyStringSlice ¶
func CreateDirIfNotExists ¶
CreateDirIfNotExists creates dir if it does not exist
func CreateHttpClientWithDialContext ¶
func CreateHttpClientWithDialContext(dial func(ctx context.Context, network, addr string) (net.Conn, error)) (*http.Transport, *http.Client, error)
CreateHttpClientWithDialContext create a httpclient with dialcontext func
func DeepCopyStringSlice ¶
func GetEnvOrDefault ¶
func GetLocalTimezone ¶
func GetLocalTimezone() string
func IsContextDone ¶
func IsContextNotDone ¶
func IsNotImplemented ¶
func MaybeCloseRead ¶
func MaybeCloseRead(conn interface{}) error
func MaybeCloseWrite ¶
func MaybeCloseWrite(conn interface{}) error
func MaybeIOClose ¶
func MaybeIOClose(i interface{}) error
func MaybeSetDeadline ¶
func MergeStringMapTo ¶
MergeStringMapTo merges one string map to another
func NewClientTLSFromBase64 ¶
func NewClientTLSFromBase64(certBase64, serverNameOverride string) (credentials.TransportCredentials, error)
func ParseDuration ¶
ParseDuration parse any object that like a duration str to duration for example: "100ms" -> 100ms 100 -> 100ms 100.0 -> 100ms
func ParseStringSliceEnvToMap ¶
ParseStringSliceEnvToMap parse envs from []string to map[string]string
func RandBetween ¶
func RandBetween64 ¶
func ReplaceHost ¶
func ReplaceHostToLocalhost ¶
func ReverseStringSlice ¶
func ReverseStringSlice(a []string)
func SetLocalIp ¶
func SetLocalIp(ip string)
func StringSliceContains ¶
func StringSliceFind ¶
func SubBytesMax ¶
SubBytesMax returns a sub slice with max length limit
func SubContextTimeout ¶
func SubContextTimeoutE ¶
func SubstringMax ¶
func SyncMapSize ¶
func ToJsonBuffer ¶
func ToJsonBufferE ¶
func ToJsonBytes ¶
func ToJsonBytes(v interface{}) []byte
func ToJsonString ¶
func ToJsonString(v interface{}) string
ToJsonString convert v to json string ignoring any error
func TransformStringSlice ¶
func ZeroCopyStringToBytes ¶
Types ¶
type AlignedTimer ¶
type AlignedTimer struct { // C returns the time chan. // Note that the value in chan may be different with the value returned by Next(). // Please refer to the value returned by Next(). C <-chan time.Time // contains filtered or unexported fields }
AlignedTimer emit aligned time.Time. [align+offset, 2*align+offset, 3*align+offset, ...] When skipExpiredWindow is true, if wall time is after next 'n*align+offset' when calling Next(), it is skipped, and the next emit time will be (n+1)*align+offset. When skipExpiredWindow is false, if wall time is after next 'n*align+offset' when calling Next(), it will trigger an emit right now. If skipFirstTimer is true, it ensures that the (first emit time - now) >= align. Otherwise, first emit may be trigger within 'align' time. Example: align=5s offset=2s, skipExpiredWindow=true, skipFirstTimer=false Now is 00:00:6s, the emitted times will be: 00:00:07, 00:00:12, 00:00:17, ... Assuming task executing at 00:00:07 is very heavy, and when it is completed, the time exceeds 00:00:12. So the next emit time is 00:00:17. The emitted times will be: 00:00:07, 00:00:17, ...
func NewAlignedTimer ¶
func (*AlignedTimer) LoadState ¶
func (t *AlignedTimer) LoadState(b []byte) error
LoadState loads timer state from []byte
func (*AlignedTimer) Next ¶
func (t *AlignedTimer) Next() time.Time
Next triggers emit, returns next emit time. The returned time may before time.Now() if 'skipExpiredWindow' is false.
func (*AlignedTimer) NextEmitTime ¶
func (t *AlignedTimer) NextEmitTime() time.Time
NextEmitTime returns expected next emit time. It may have: 'next emit time' < 'time.Now()'
func (*AlignedTimer) SaveState ¶
func (t *AlignedTimer) SaveState() ([]byte, error)
SaveState saves current timer state into []byte
type DnsCacheHelper ¶
type DnsCacheHelper struct {
// contains filtered or unexported fields
}
func NewDnsCacheHelper ¶
func NewDnsCacheHelper() *DnsCacheHelper
func (*DnsCacheHelper) NewHttpClient ¶
func (h *DnsCacheHelper) NewHttpClient() *http.Client
func (*DnsCacheHelper) Start ¶
func (h *DnsCacheHelper) Start()
func (*DnsCacheHelper) Stop ¶
func (h *DnsCacheHelper) Stop()
type ReadWriterConn ¶
func (*ReadWriterConn) Close ¶
func (r *ReadWriterConn) Close() error
func (*ReadWriterConn) CloseRead ¶
func (r *ReadWriterConn) CloseRead() error
func (*ReadWriterConn) CloseWrite ¶
func (r *ReadWriterConn) CloseWrite() error
func (*ReadWriterConn) LocalAddr ¶
func (r *ReadWriterConn) LocalAddr() net.Addr
func (*ReadWriterConn) RemoteAddr ¶
func (r *ReadWriterConn) RemoteAddr() net.Addr
func (*ReadWriterConn) SetDeadline ¶
func (r *ReadWriterConn) SetDeadline(t time.Time) error
func (*ReadWriterConn) SetReadDeadline ¶
func (r *ReadWriterConn) SetReadDeadline(t time.Time) error
func (*ReadWriterConn) SetWriteDeadline ¶
func (r *ReadWriterConn) SetWriteDeadline(t time.Time) error
type ReaderCloserFunc ¶
ReaderCloserFunc wraps an io.Reader. It calls Closer func when reader meets io.EOF.
type ReaderReadHook ¶
type ReaderReadHook struct { Reader io.Reader Before func() After func(p []byte, n int, err error) }
func (*ReaderReadHook) Close ¶
func (s *ReaderReadHook) Close() error
type SortStringsByLength ¶
type SortStringsByLength []string
func (SortStringsByLength) Len ¶
func (s SortStringsByLength) Len() int
func (SortStringsByLength) Less ¶
func (s SortStringsByLength) Less(i, j int) bool
func (SortStringsByLength) Swap ¶
func (s SortStringsByLength) Swap(i, j int)
type StopSignal ¶
type StopSignal struct { C chan struct{} // contains filtered or unexported fields }
func NewStopSignal ¶
func NewStopSignal() *StopSignal
func (*StopSignal) IsStopAsked ¶
func (s *StopSignal) IsStopAsked() bool
func (*StopSignal) StopAndWait ¶
func (s *StopSignal) StopAndWait()
func (*StopSignal) WaitStopped ¶
func (s *StopSignal) WaitStopped()