utils

package
v4.4.5 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRtpDiff = 65000 //相邻两个包之间的最大差值

Variables

View Source
var ErrTooLarge = errors.New("IOBuffer: too large")

Functions

func DecodeGbk

func DecodeGbk(v interface{}, body []byte) error

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

func Get

func Get() *bytes.Buffer

Get returns an empty byte buffer from the pool.

Got byte buffer may be returned to the pool via Put call. This reduces the number of memory allocations required for byte buffer management.

func NewError

func NewError(err error, params ...interface{}) error

NewError NewError

func PrintStack

func PrintStack()

func Put

func Put(b *bytes.Buffer)

Put returns byte buffer to the pool.

bytes.Buffer.B mustn't be touched after returning it to the pool. Otherwise data races will occur.

func RandNum16String

func RandNum16String(n int) string

func RandNumString

func RandNumString(n int) string

func RandString

func RandString(n int) string

func ResolveSelfIP

func ResolveSelfIP() (net.IP, error)

ResolveSelfIP ResolveSelfIP

func ToJSONString

func ToJSONString(v interface{}) string

func ToPrettyString

func ToPrettyString(v interface{}) string

Types

type Error

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

Error Error

func (*Error) Error

func (err *Error) Error() string

type IOBuffer

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

func (*IOBuffer) Len

func (b *IOBuffer) Len() int

func (*IOBuffer) Next

func (b *IOBuffer) Next(n int) []byte

func (*IOBuffer) ReadByte

func (b *IOBuffer) ReadByte() (byte, error)

func (*IOBuffer) ReadN

func (b *IOBuffer) ReadN(length int) ([]byte, error)

func (*IOBuffer) Reset

func (b *IOBuffer) Reset()

func (*IOBuffer) Skip

func (b *IOBuffer) Skip(n int) (err error)

func (*IOBuffer) Uint16

func (b *IOBuffer) Uint16() (uint16, error)

func (*IOBuffer) Uint32

func (b *IOBuffer) Uint32() (uint32, error)

func (*IOBuffer) Write

func (b *IOBuffer) Write(p []byte) (n int, err error)

type Pool

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

Pool represents byte buffer pool.

Distinct pools may be used for distinct types of byte buffers. Properly determined byte buffer types with their own pools may help reducing memory waste.

func (*Pool) Get

func (p *Pool) Get() *bytes.Buffer

Get returns new byte buffer with zero length.

The byte buffer may be returned to the pool via Put after the use in order to minimize GC overhead.

func (*Pool) Put

func (p *Pool) Put(b *bytes.Buffer)

Put releases byte buffer obtained via Get to the pool.

The buffer mustn't be accessed after returning to the pool.

type PriorityQueueRtp

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

func NewPqRtp

func NewPqRtp() *PriorityQueueRtp

func (*PriorityQueueRtp) Empty

func (p *PriorityQueueRtp) Empty()

func (*PriorityQueueRtp) Len

func (p *PriorityQueueRtp) Len() int

func (*PriorityQueueRtp) Pop

func (p *PriorityQueueRtp) Pop() (rtp.Packet, error)

func (*PriorityQueueRtp) Push

func (p *PriorityQueueRtp) Push(v rtp.Packet)

type ZapLogger

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

func NewZapLogger

func NewZapLogger(log *m7slog.Logger, prefix string, fields log.Fields) (z *ZapLogger)

func (*ZapLogger) Debug

func (l *ZapLogger) Debug(args ...interface{})

func (*ZapLogger) Debugf

func (l *ZapLogger) Debugf(format string, args ...interface{})

func (*ZapLogger) Error

func (l *ZapLogger) Error(args ...interface{})

func (*ZapLogger) Errorf

func (l *ZapLogger) Errorf(format string, args ...interface{})

func (*ZapLogger) Fatal

func (l *ZapLogger) Fatal(args ...interface{})

func (*ZapLogger) Fatalf

func (l *ZapLogger) Fatalf(format string, args ...interface{})

func (*ZapLogger) Fields

func (l *ZapLogger) Fields() log.Fields

func (*ZapLogger) Info

func (l *ZapLogger) Info(args ...interface{})

func (*ZapLogger) Infof

func (l *ZapLogger) Infof(format string, args ...interface{})

func (*ZapLogger) Panic

func (l *ZapLogger) Panic(args ...interface{})

func (*ZapLogger) Panicf

func (l *ZapLogger) Panicf(format string, args ...interface{})

func (*ZapLogger) Prefix

func (l *ZapLogger) Prefix() string

func (*ZapLogger) Print

func (l *ZapLogger) Print(args ...interface{})

func (*ZapLogger) Printf

func (l *ZapLogger) Printf(format string, args ...interface{})

func (*ZapLogger) SetLevel

func (l *ZapLogger) SetLevel(level uint32)

func (*ZapLogger) Trace

func (l *ZapLogger) Trace(args ...interface{})

func (*ZapLogger) Tracef

func (l *ZapLogger) Tracef(format string, args ...interface{})

func (*ZapLogger) Warn

func (l *ZapLogger) Warn(args ...interface{})

func (*ZapLogger) Warnf

func (l *ZapLogger) Warnf(format string, args ...interface{})

func (*ZapLogger) WithFields

func (l *ZapLogger) WithFields(fields map[string]interface{}) log.Logger

func (*ZapLogger) WithPrefix

func (l *ZapLogger) WithPrefix(prefix string) log.Logger

Jump to

Keyboard shortcuts

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