util

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDate

func FormatDate(t time.Time) string

func FormatTimestamp

func FormatTimestamp(t int64) string

func HandleCrash

func HandleCrash(handlers ...func(interface{}))

func Max

func Max(a, b uint64) uint64

func Min

func Min(a, b uint64) uint64

func PutUvarint64

func PutUvarint64(buf []byte, x uint64) int

func RunWorker

func RunWorker(f func(), handlers ...func(interface{}))

func RunWorkerUtilStop

func RunWorkerUtilStop(f func(), stopCh <-chan struct{}, handlers ...func(interface{}))

func Uvarint64

func Uvarint64(buf []byte) (uint64, int)

Types

type AtomicBool

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

func (*AtomicBool) CompareAndSet

func (b *AtomicBool) CompareAndSet(expect, update bool) bool

func (*AtomicBool) Get

func (b *AtomicBool) Get() bool

func (*AtomicBool) Set

func (b *AtomicBool) Set(newValue bool)

type AtomicUInt64

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

func (*AtomicUInt64) Add

func (a *AtomicUInt64) Add(v uint64) uint64

func (*AtomicUInt64) CompareAndSwap

func (a *AtomicUInt64) CompareAndSwap(o, n uint64) bool

func (*AtomicUInt64) Get

func (a *AtomicUInt64) Get() uint64

func (*AtomicUInt64) Incr

func (a *AtomicUInt64) Incr() uint64

func (*AtomicUInt64) Set

func (a *AtomicUInt64) Set(v uint64)

type BufferReader

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

func NewBufferReader

func NewBufferReader(reader io.Reader, size int) *BufferReader

func (*BufferReader) Grow

func (br *BufferReader) Grow(n int)

func (*BufferReader) ReadFull

func (br *BufferReader) ReadFull(min int) (data []byte, err error)

func (*BufferReader) Reset

func (br *BufferReader) Reset()

type BufferWriter

type BufferWriter struct {
	*bufio.Writer
}

func NewBufferWriter

func NewBufferWriter(wr io.Writer, size int) *BufferWriter

type ConnTimeout

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

func DialTimeout

func DialTimeout(addr string, connTime time.Duration) (*ConnTimeout, error)

func NewConnTimeout

func NewConnTimeout(conn net.Conn) *ConnTimeout

func (*ConnTimeout) Close

func (c *ConnTimeout) Close() error

func (*ConnTimeout) Read

func (c *ConnTimeout) Read(p []byte) (n int, err error)

func (*ConnTimeout) RemoteAddr

func (c *ConnTimeout) RemoteAddr() string

func (*ConnTimeout) SetReadTimeout

func (c *ConnTimeout) SetReadTimeout(timeout time.Duration)

func (*ConnTimeout) SetWriteTimeout

func (c *ConnTimeout) SetWriteTimeout(timeout time.Duration)

func (*ConnTimeout) Write

func (c *ConnTimeout) Write(p []byte) (n int, err error)

type Uint64Slice

type Uint64Slice []uint64

func (Uint64Slice) Len

func (p Uint64Slice) Len() int

func (Uint64Slice) Less

func (p Uint64Slice) Less(i, j int) bool

func (Uint64Slice) Swap

func (p Uint64Slice) Swap(i, j int)

Jump to

Keyboard shortcuts

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