v0.7.0

Wire Protocol

Last updated

This page specifies the frame format, request ops, and error kinds that ToriiDB daemon clients and the server exchange over the unix socket.

Wire Protocol

Both directions use the same frame:

[4-byte big-endian payload length][JSON payload]

Frames larger than 8 MiB are refused by readFrame. A payload that is not valid JSON gets a bad_request response on the same connection.

op request fields success response
get db key {"record":{db,key,type,content,created_at,updated_at?,expire_at?}}
entries db pattern contains? after? limit? {"entries":[<record>,...]}
set db key content expire_at? vector? {}
del db keys {"count":<removed>}
ttl db key {"ttl":<seconds>}
expire db keys ttl {"count":<applied>}
keys db pattern limit? page? {"list":{db,page,limit,total,keys}}
vsearch db text pattern limit? {"keys":[...]}
embedder none {"embedder":<bool>}

Failures return {"error":"...","kind":"..."}:

kind Client error Typical cause
not_found ErrNotFound get/ttl on a missing key
bad_request ErrBadRequest invalid db index, missing pattern/keys/text, ttl <= 0, invalid content, unknown op
no_embedder ErrNoEmbedder set with vector or vsearch without an API key
internal plain error store or embedding failure
中文