mstar.api_server.rust_frontend#
The Rust axum frontend in front of APIServer.
mstar-server (rust/server/) owns the HTTP surface — routes, OpenAI
translation, SSE/NDJSON streaming, uploads, CORS — and speaks a flattened
msgpack protocol over the Rust ZMQ transport to this bridge, which
drives the existing Python data plane (APIServer.submit_request /
iter_result_chunks / abort_submission; preprocessing and the conductor
protocol are untouched):
- frontend -> bridge: {t:”submit”, rid, sub, text, file_paths,
input_modalities, output_modalities, model_kwargs, prompt_parts, streaming} | {t:”abort”, rid, sub}
{t:”ping”, rid, sub}{t:”metrics”, rid, sub, refusals:{route, status, count}}- bridge -> frontend: {t:”chunk”, rid, sub, modality, data(bin), metadata}
{t:”err”, rid, sub, msg} | {t:”done”, rid, sub}{t:”pong”, rid, sub}{t:”metrics”, rid, sub, data(bin), metadata}
A metrics request carries the frontend’s cumulative refusal counts as
three parallel lists (route template, status, count), which the API server
exports as mstar_http_refusals_total. The reply is what GET /metrics
serves on the Python frontend: the text rendered from APIServer.metrics
with its content_type in metadata, or empty metadata when metrics
are off (a 404; the counts are then ignored).
sub names one submission and is never reused. A client may resubmit its
rid as soon as it drops a stream, and that stream’s done or late
chunks can cross the retry, so everything about a submission is addressed by
sub. The frontend refuses a rid still in flight with a 409 itself and
sends a dropped stream’s abort before it frees the rid, so the abort
arrives here before the retry’s submit.
The submit shape is APIServer.submit_request’s signature verbatim — the
protocol was designed by flattening it. prompt_parts travels for a chat
only, one map of PromptPart’s fields per part. The bridge mesh lives in
its own socket dir (private to the frontend/bridge pair), so entity names
never collide with the conductor/worker mesh.
Opt-in: mstar-serve --rust-frontend replaces uvicorn.run with the
mstar-server binary + this loop. Everything else in the process
(preprocess worker, conductor spawn, tensor transport) is identical. The
frontend enforces the API key (--api-key / MSTAR_API_KEY) itself; the
bridge socket is private to the pair.
Module Attributes
Upper bound on one blocking receive, so |
|
The model's adapter class in |
Functions
|
Resolve the |
|
|
|
The class name of |
Classes
|
The serve loop between the Rust frontend and |
- mstar.api_server.rust_frontend.BRIDGE_RECV_WAIT_S = 0.05#
Upper bound on one blocking receive, so
stop()is noticed promptly and the loop stays responsive to shutdown. Not a latency knob: an arriving message ends the wait immediately.
- mstar.api_server.rust_frontend.OPENAI_ADAPTER_ENV = 'MSTAR_OPENAI_ADAPTER'#
The model’s adapter class in
ADAPTER_REGISTRY;mstar-serverpicks its OpenAI translation by it (Adapter::from_python).
- class mstar.api_server.rust_frontend.RustFrontendBridge(server, bridge_dir)[source]#
Bases:
objectThe serve loop between the Rust frontend and
APIServer.- Parameters:
bridge_dir (str)
- mstar.api_server.rust_frontend.find_server_binary(explicit=None)[source]#
Resolve the
mstar-serverbinary: explicit arg,MSTAR_SERVER_BIN,$PATH, then the in-repo release build.