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§
Constants§
- HEADER_
LEN tag+id. Five bytes, which is already noise beside a WebSocket frame’s own 2–14 byte header — the reasonidis a comfortableu32instead of au16with 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::Databecause 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