Skip to main content

Crate objectiveai_db_proxy

Crate objectiveai_db_proxy 

Source
Expand description

A Postgres-over-WebSocket conduit for ObjectiveAI plugin containers.

A container cannot reach the machine hosting it, so a plugin inside one cannot dial the ObjectiveAI database. This binary is copied into the container — the way objectiveai-mcp-laboratory already is — and bridges the two legs that DO work: it serves ordinary Postgres clients on a fixed loopback port, and accepts a WebSocket from the laboratory host, which dials in and relays to the real database.

Every Postgres connection rides that one socket, keyed by a small numeric id ([frame]). The point of shipping it as a separate binary is that a plugin — in any language, using the plugin framework or not — needs to know none of this. It sees a Postgres server on localhost.

There is NO configuration: the addresses and ports are hardcoded (POSTGRES_PORT, HOST_PORT), because a binary that gets podman exec’d into an image somebody else built should not be reconfigurable by that image’s environment. run therefore takes nothing, and the binary at main.rs only sets up logging and calls it.

Structs§

Conduit
Host
The attached host relay: where to put frames bound for the database, and the epoch identifying which relay that is.
Servers

Enums§

Frame

Constants§

HEADER_LEN
tag + id. Five bytes, which is already noise beside a WebSocket frame’s own 2–14 byte header — the reason id is a comfortable u32 instead of a u16 with wraparound bookkeeping.
HOST_ADDRESS
Where the laboratory host dials in. 0.0.0.0, because a published container port does not reach a loopback-bound listener.
HOST_PORT
The port the laboratory host dials, published out of the container.
POSTGRES_ADDRESS
Where Postgres clients connect. Loopback: in-container only.
POSTGRES_PORT
The port Postgres clients connect to — what the launcher names in OBJECTIVEAI_POSTGRES_URL.
TAG_CLOSE
TAG_DATA
TAG_OPEN

Functions§

encode_close
encode_data
Frame a freshly-read chunk. Takes a slice rather than Frame::Data because this is the hot path — going through the enum would buy an extra copy of every byte the database ever sends.
encode_open
run
serve
setup