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_request; preprocessing and the conductor protocol are untouched):

frontend -> bridge: {t:”submit”, rid, text, file_paths,

input_modalities, output_modalities, model_kwargs, streaming} | {t:”abort”, rid}

bridge -> frontend: {t:”chunk”, rid, modality, data(bin), metadata}
{t:”err”, rid, msg} | {t:”done”, rid}

The submit shape is APIServer.submit_request’s signature verbatim — the protocol was designed by flattening it. 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.

Module Attributes

BRIDGE_RECV_WAIT_S

Upper bound on one blocking receive, so stop() is noticed promptly and the loop stays responsive to shutdown.

Functions

find_server_binary([explicit])

Resolve the mstar-server binary: explicit arg, MSTAR_SERVER_BIN, $PATH, then the in-repo release build.

launch_rust_server(binary, model_name, port, ...)

Classes

RustFrontendBridge(server, bridge_dir)

The serve loop between the Rust frontend and APIServer.

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.

class mstar.api_server.rust_frontend.RustFrontendBridge(server, bridge_dir)[source]#

Bases: object

The serve loop between the Rust frontend and APIServer.

Parameters:

bridge_dir (str)

run()[source]#

Blocking serve loop (the uvicorn.run replacement).

Return type:

None

stop()[source]#
Return type:

None

mstar.api_server.rust_frontend.find_server_binary(explicit=None)[source]#

Resolve the mstar-server binary: explicit arg, MSTAR_SERVER_BIN, $PATH, then the in-repo release build.

Parameters:

explicit (str | None)

Return type:

str

mstar.api_server.rust_frontend.launch_rust_server(binary, model_name, port, bridge_dir, upload_dir)[source]#
Parameters:
  • binary (str)

  • model_name (str)

  • port (int)

  • bridge_dir (str)

  • upload_dir (str)

Return type:

Popen