Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
CompressZstd compresses data using zstd with a pooled encoder.
func DecompressZstd ¶
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.
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.
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 (*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.