libs

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const BufByte = 1024 * 1024 * 4
View Source
const (
	DefaultFieldForMessage = "message"
)

Variables

View Source
var Logger *utils.LoggerType
View Source
var (
	MustIncludeFileds = []string{
		"tag",
		"@timestamp",
		"msgid",
		"container_id",
		"container_name",
		"level",
		"datasource",
	}
)

Functions

func AbsInt added in v1.12.0

func AbsInt(n int) int

AbsInt return abs(int)

func FlattenMap

func FlattenMap(data map[string]interface{}, delimiter string)

func LoadTagReplaceEnv added in v1.12.0

func LoadTagReplaceEnv(env, tag string) string

LoadTagReplaceEnv replace `{env}` to env

"spring.{env}" -> "spring.sit"

func LoadTagsAppendEnv

func LoadTagsAppendEnv(env string, tags []string) []string

LoadTagsAppendEnv append env to tags slice

[]string{"spring"} -> []string{"spring.sit"}

func LoadTagsMapAppendEnv added in v1.10.4

func LoadTagsMapAppendEnv(env string, tags map[string]interface{}) map[string]interface{}

LoadTagsMapAppendEnv append env to tags map

map[string]interface{}{"spring": "xxx"} -> map[string]interface{}{"spring.sit": "xxx"}

func LoadTagsReplaceEnv added in v1.12.0

func LoadTagsReplaceEnv(env string, tags []string) []string

LoadTagsReplaceEnv replace `{env}` to env

[]string{"spring.{env}"} -> []string{"spring.sit"}

func RegexNamedSubMatch

func RegexNamedSubMatch(r *regexp.Regexp, log []byte, subMatchMap map[string]interface{}) error

func TemplateWithMap added in v1.9.3

func TemplateWithMap(tpl string, data map[string]interface{}) string

TemplateWithMap replace `${var}` in template string

func TemplateWithMapAndRegexp added in v1.9.3

func TemplateWithMapAndRegexp(tplReg *regexp.Regexp, tpl string, data map[string]interface{}) string

TemplateWithMapAndRegexp replace `${var}` in template string

Types

type CounterIft

type CounterIft interface {
	Count() int64
	CountN(int64) int64
}

type FluentBatchMsg

type FluentBatchMsg []interface{}

func (*FluentBatchMsg) DecodeMsg

func (z *FluentBatchMsg) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (FluentBatchMsg) EncodeMsg

func (z FluentBatchMsg) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (FluentBatchMsg) MarshalMsg

func (z FluentBatchMsg) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (FluentBatchMsg) Msgsize

func (z FluentBatchMsg) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*FluentBatchMsg) UnmarshalMsg

func (z *FluentBatchMsg) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type FluentEncoder

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

func NewFluentEncoder

func NewFluentEncoder(writer io.Writer) *FluentEncoder

func (*FluentEncoder) Encode

func (e *FluentEncoder) Encode(msg *FluentMsg) error

func (*FluentEncoder) EncodeBatch

func (e *FluentEncoder) EncodeBatch(tag string, msgBatch []*FluentMsg) (err error)

func (*FluentEncoder) Flush

func (e *FluentEncoder) Flush() error

type FluentMsg

type FluentMsg struct {
	Tag     string
	Message map[string]interface{}
	Id      int64
	ExtIds  []int64
}

FluentMsg is the structure of fluent message

func (*FluentMsg) DecodeMsg

func (z *FluentMsg) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*FluentMsg) EncodeMsg

func (z *FluentMsg) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*FluentMsg) MarshalMsg

func (z *FluentMsg) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*FluentMsg) Msgsize

func (z *FluentMsg) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*FluentMsg) UnmarshalMsg

func (z *FluentMsg) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Timer

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

func NewTimer

func NewTimer(cfg *TimerConfig) *Timer

func (*Timer) Reset

func (t *Timer) Reset(lastT time.Time)

func (*Timer) Sleep

func (t *Timer) Sleep()

func (*Timer) Tick

func (t *Timer) Tick(now time.Time) bool

type TimerConfig

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

func NewTimerConfig

func NewTimerConfig(initWaitTs, maxWaitTs, waitTs, timeoutTs time.Duration, nWaits, nWaitsToDouble int) *TimerConfig

type TinyFluentRecord

type TinyFluentRecord struct {
	Timestamp uint64
	Data      map[string]interface{}
}

Jump to

Keyboard shortcuts

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