common

package
v0.8.12 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultKeepaliveInterval is default keepalive interval duration.
	DefaultKeepaliveInterval = 20 * time.Second
	// DefaultKeepaliveMaxLifetime is default keepalive max lifetime.
	DefaultKeepaliveMaxLifetime = 90 * time.Second
)

Variables

This section is empty.

Functions

func AppendPrettyHexDump added in v0.6.0

func AppendPrettyHexDump(dump *strings.Builder, b []byte)

AppendPrettyHexDump appends bytes to string builder.

func CloneBytes added in v0.7.0

func CloneBytes(b []byte) []byte

func CountBorrowed added in v0.7.0

func CountBorrowed() int64

CountBorrowed returns borrowed ByteBuff amount.

func PrettyHexDump added in v0.6.0

func PrettyHexDump(b []byte) string

PrettyHexDump converts bytes to pretty hex dump string.

func RandAlphabetic

func RandAlphabetic(n int) (s string)

RandAlphabetic returns a string with random alphabets.

func RandAlphanumeric

func RandAlphanumeric(n int) (s string)

RandAlphanumeric returns a string with random alphabets and numbers.

func RandFloat64

func RandFloat64() (v float64)

RandFloat64 returns a random float64.

func RandIntn

func RandIntn(n int) (v int)

RandIntn returns a random int.

func ReturnByteBuff added in v0.7.0

func ReturnByteBuff(b *ByteBuff)

ReturnByteBuff returns a ByteBuff to pool.

func SafeCloseDoneChan added in v0.7.0

func SafeCloseDoneChan(c chan<- struct{}) (ok bool)

func ToMilliseconds added in v0.7.0

func ToMilliseconds(duration time.Duration) int64

func TryRelease added in v0.7.0

func TryRelease(input interface{})

Types

type ByteBuff

type ByteBuff bytes.Buffer

ByteBuff provides byte buffer, which can be used for minimizing.

func BorrowByteBuff added in v0.7.0

func BorrowByteBuff() *ByteBuff

BorrowByteBuff borrows a ByteBuff from pool.

func (*ByteBuff) Bytes

func (b *ByteBuff) Bytes() []byte

Bytes returns all bytes in ByteBuff.

func (*ByteBuff) Len

func (b *ByteBuff) Len() (n int)

Len returns size of ByteBuff.

func (*ByteBuff) Reset

func (b *ByteBuff) Reset()

Reset resets ByteBuff.

func (*ByteBuff) Write

func (b *ByteBuff) Write(bs []byte) (int, error)

Write writes bytes to current ByteBuff.

func (*ByteBuff) WriteByte

func (b *ByteBuff) WriteByte(c byte) error

WriteByte writes a byte to current ByteBuff.

func (*ByteBuff) WriteString added in v0.6.0

func (b *ByteBuff) WriteString(s string) (err error)

WriteString writes a string to current ByteBuff.

func (*ByteBuff) WriteTo

func (b *ByteBuff) WriteTo(w io.Writer) (int64, error)

WriteTo writes bytes to writer.

type Cond added in v0.6.0

type Cond struct {
	L sync.Locker
	// contains filtered or unexported fields
}

Cond is a customized Cond which support context. See https://gist.github.com/zviadm/c234426882bfc8acba88f3503edaaa36#file-cond2-go

func NewCond added in v0.6.0

func NewCond(l sync.Locker) *Cond

NewCond creates a new Cond.

func (*Cond) Broadcast added in v0.6.0

func (c *Cond) Broadcast()

Broadcast broadcast Cond.

func (*Cond) NotifyChan added in v0.6.0

func (c *Cond) NotifyChan() <-chan struct{}

NotifyChan returns readonly notify chan.

func (*Cond) Wait added in v0.6.0

func (c *Cond) Wait(ctx context.Context) (isCtx bool)

Wait waits Cond.

type Releasable added in v0.7.0

type Releasable interface {
	IncRef() int32
	RefCnt() int32
	Release()
}

Jump to

Keyboard shortcuts

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