Documentation
¶
Index ¶
- Variables
- func LBRelease(b *CByteBuf)
- func RegisterMetricsHandler(handler MetricsWriter)
- func Release(b *CByteBuf)
- type CByteBuf
- func (b *CByteBuf) AppendBytes(dst []byte) []byte
- func (b *CByteBuf) AppendString(dst string) string
- func (b *CByteBuf) Bytes() []byte
- func (b *CByteBuf) Cap() int
- func (b *CByteBuf) Grow(cap int) error
- func (b *CByteBuf) GrowDelta(delta int) error
- func (b *CByteBuf) GrowLen(len int) error
- func (b *CByteBuf) Len() int
- func (b *CByteBuf) ReadFrom(r io.Reader) (n int64, err error)
- func (b *CByteBuf) Release()
- func (b *CByteBuf) Reset()
- func (b *CByteBuf) ResetLen()
- func (b *CByteBuf) String() string
- func (b *CByteBuf) Write(data []byte) (int, error)
- func (b *CByteBuf) WriteBool(v bool) (int, error)
- func (b *CByteBuf) WriteByte(c byte) error
- func (b *CByteBuf) WriteFloat(f float64, prec int) (int, error)
- func (b *CByteBuf) WriteInt(i int64) (int, error)
- func (b *CByteBuf) WriteMarshallerTo(m MarshallerTo) (int, error)
- func (b *CByteBuf) WriteString(s string) (int, error)
- func (b *CByteBuf) WriteTo(w io.Writer) (int64, error)
- func (b *CByteBuf) WriteUint(u uint64) (int, error)
- type DummyMetrics
- type LBPool
- type MarshallerTo
- type MetricsWriter
- type Pool
Constants ¶
This section is empty.
Variables ¶
var ( ErrOk error = nil ErrBadAlloc = errors.New("bad alloc on buffer init or grow") ErrNegativeCap = errors.New("negative cap on the grow") ErrNegativeRead = errors.New("reader returned negative count from Read") ErrNilMarshaller = errors.New("marshaller object is nil") )
var ( // LBP is a default instance of LB pool for simple cases. // Just call cbytebuf.LBAcquire() and cbytebuf.LBRelease(). LBP = LBPool{Size: 1000} )
Functions ¶
func LBRelease ¶
func LBRelease(b *CByteBuf)
LBRelease puts byte buffer back to default LB pool instance.
func RegisterMetricsHandler ¶
func RegisterMetricsHandler(handler MetricsWriter)
RegisterMetricsHandler registers new metrics handler.
Types ¶
type CByteBuf ¶
type CByteBuf struct {
// contains filtered or unexported fields
}
CByteBuf is a variable-size alloc-free buffer based on cbyte array. Also, no escapes to the heap since buffer doesn't contain any pointer.
func LBAcquire ¶
func LBAcquire() *CByteBuf
LBAcquire gets byte buffer from default LB pool instance.
func (*CByteBuf) AppendBytes ¶
AppendBytes appends buffer value to destination and return it.
func (*CByteBuf) AppendString ¶
AppendString appends buffer value to destination string and return it.
func (*CByteBuf) GrowDelta ¶
GrowDelta increases or decrease capacity of the buffer using delta value.
Delta may be negative, but if delta will less than -capacity, the error will be triggered.
func (*CByteBuf) GrowLen ¶
GrowLen increases or decrease length of the buffer.
May increase capacity if needed.
func (*CByteBuf) Release ¶
func (b *CByteBuf) Release()
Release manually releases of the underlying byte array.
Using the buffer data after call this func may crash your app. This method truncates buffer's capacity.
func (*CByteBuf) Reset ¶
func (b *CByteBuf) Reset()
Reset all data accumulated in buffer.
This method made special to use together with pools. Using the buffer data after call this func may crash your app. Buffer capacity keeps to reduce amount of further CGO calls.
func (*CByteBuf) ResetLen ¶
func (b *CByteBuf) ResetLen()
ResetLen resets buffer length without releasing memory.
func (*CByteBuf) WriteFloat ¶
WriteFloat writes float value in the buffer.
func (*CByteBuf) WriteMarshallerTo ¶
func (b *CByteBuf) WriteMarshallerTo(m MarshallerTo) (int, error)
WriteMarshallerTo marshals data of struct implemented MarshallerTo interface into the buffer.
func (*CByteBuf) WriteString ¶
WriteString implements io.StringWriter.
type DummyMetrics ¶
type DummyMetrics struct{}
DummyMetrics writer. Used by default and does nothing.
func (DummyMetrics) PoolAcquire ¶
func (m DummyMetrics) PoolAcquire(_ uint64)
func (DummyMetrics) PoolRelease ¶
func (m DummyMetrics) PoolRelease(_ uint64)
type LBPool ¶
LBPool is a pool implementation based on lbpool.Pool.
type MarshallerTo ¶
MarshallerTo interface to write struct like Protobuf.
type MetricsWriter ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a pool implementation based on sync.Pool.
var P Pool
P is a default instance of native pool for simple cases. Just call cbytebuf.Acquire() and cbytebuf.Release().