skeg_client/binary
Client for skeg’s native binary protocol (native v1 frames).
Native v1 has no authentication: use it only on a server without tenant
auth. On a skeg 0.8 server, vindex_create over v1 creates durable disk
indexes of kind KindInt8 only; BackendFlat, KindF32 and
KindBinary are refused by the server with ServerError. Use the RESP3
modules (skeg_client/vector) for other index kinds, flat indexes,
payloads, filters and batches.
Frames have a 24-byte header, little-endian throughout.
Types
pub type Backend {
BackendFlat
BackendDiskVamana
}
Constructors
-
BackendFlat -
BackendDiskVamana
pub type ShardStats {
ShardStats(
shard_id: Int,
cache_bytes: Int,
cache_evictions: Int,
n_keys: Int,
cache_budget: Int,
)
}
Constructors
-
ShardStats( shard_id: Int, cache_bytes: Int, cache_evictions: Int, n_keys: Int, cache_budget: Int, )
pub type SkegError {
ConnectError(reason: String)
IoError(reason: String)
ProtocolError(reason: String)
ServerError(code: Int, message: String)
}
Constructors
-
ConnectError(reason: String) -
IoError(reason: String) -
ProtocolError(reason: String) -
ServerError(code: Int, message: String)
pub type SockHandle
pub type VindexInfo {
VindexInfo(
name: String,
dim: Int,
kind: Int,
backend: Int,
n_vectors: Int,
)
}
Constructors
-
VindexInfo( name: String, dim: Int, kind: Int, backend: Int, n_vectors: Int, )
Values
pub fn decode_err(body: BitArray) -> SkegError
Decode an op_err response body into a ServerError. Public so the
wire-level decoding of the error-code byte (including codes this
build does not recognise, such as a future addition past
err_backpressure) can be exercised directly in tests without a
live server.
pub const err_backpressure: Int
pub const err_internal: Int
pub const err_invalid_request: Int
pub const err_not_found: Int
pub fn get(
socket: Socket,
key: BitArray,
) -> Result(option.Option(BitArray), SkegError)
pub fn is_retryable(code: Int) -> Bool
Does this native error code mean “send the same request again is
worth doing”? Only err_backpressure (0x04) is retryable. A code
this build does not recognise is NOT retryable: guessing that an
unknown refusal clears on its own is how a client loops on a
permanent one. Mirrors ErrCode::is_retryable in skeg-proto.
pub fn mget(
socket: Socket,
keys: List(BitArray),
) -> Result(List(option.Option(BitArray)), SkegError)
pub fn shards(
socket: Socket,
) -> Result(List(ShardStats), SkegError)
Per-shard stats breakdown. The aggregate is the sum across these rows; observability tooling (skeg-top, dashboards) renders one row per shard.
pub fn vget(
socket: Socket,
name: String,
vec_id: Int,
) -> Result(option.Option(List(Float)), SkegError)
pub fn vindex_create(
socket: Socket,
name: String,
dim: Int,
kind: Kind,
backend: Backend,
) -> Result(Nil, SkegError)
pub fn vindex_list(
socket: Socket,
) -> Result(List(VindexInfo), SkegError)
List every VINDEX on the server. Returns one entry per name with
dim, kind (0=f32 / 1=int8 / 2=binary), backend (0=flat /
1=disk-vamana), and n_vectors aggregated across shards.