internal

package
v0.0.0-...-1bf0eed Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ClientNotConnectedError is returned when the client is not connected to a host.
	ClientNotConnectedError = errors.New("QRpc Client not connected to the host.")
	// StreamsListIsEmpty is returned when no streams are available in the balancer.
	StreamsListIsEmpty = errors.New("Streams list is empty.")
)

Functions

func CompressZstd

func CompressZstd(src []byte) ([]byte, error)

CompressZstd compresses data using zstd with a pooled encoder.

func DecompressZstd

func DecompressZstd(src []byte) ([]byte, error)

DecompressZstd decompresses data using zstd with a pooled decoder.

Types

type Buffer

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

Buffer is a reusable byte buffer obtained from a pool.

func (*Buffer) Bytes

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

Bytes returns the written portion of the buffer.

func (*Buffer) Release

func (b *Buffer) Release()

Release returns the buffer to the pool for reuse.

type Encoder

type Encoder interface {
	EncodeRequest(req *gen.Request) (*Buffer, error)
	EncodeResponse(resp *gen.Response) (*Buffer, error)
	EncodeEvent(req *gen.Request) (*Buffer, error)
}

Encoder serializes protobuf Request and Response messages into the qrpc wire format with optional zstd compression.

func NewEncoder

func NewEncoder() Encoder

NewEncoder creates a new Encoder.

type EncoderImpl

type EncoderImpl struct{}

EncoderImpl is a stateless encoder that pools internal buffers.

func (*EncoderImpl) EncodeEvent

func (e *EncoderImpl) EncodeEvent(req *gen.Request) (*Buffer, error)

EncodeEvent serializes a protobuf Request as a one-way event frame.

func (*EncoderImpl) EncodeRequest

func (e *EncoderImpl) EncodeRequest(req *gen.Request) (*Buffer, error)

Frame format: [4 bytes payload length][1 byte flag][protobuf payload]

payload length includes:

  • 1 byte flag
  • protobuf payload

Example: [00 00 00 15][01][protobuf...] EncodeRequest serializes a protobuf Request into a Buffer.

func (*EncoderImpl) EncodeResponse

func (e *EncoderImpl) EncodeResponse(resp *gen.Response) (*Buffer, error)

EncodeResponse serializes a protobuf Response into a Buffer.

type ShardedMap

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

ShardedMap is a concurrent map sharded into 256 buckets for O(1) request-ID-to-channel dispatch with minimal lock contention.

func NewShardedMap

func NewShardedMap() *ShardedMap

NewShardedMap creates a new empty ShardedMap.

func (*ShardedMap) Delete

func (sm *ShardedMap) Delete(key uint64)

Delete removes the value for the given key.

func (*ShardedMap) LoadAndDelete

func (sm *ShardedMap) LoadAndDelete(key uint64) (any, bool)

LoadAndDelete atomically loads and deletes the value for the given key.

func (*ShardedMap) Store

func (sm *ShardedMap) Store(key uint64, value any)

Store sets the value for the given key.

Jump to

Keyboard shortcuts

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