The frames between mix juggernaut.server and its clients (design notes §12): JSON
documents in {:packet, 4} frames over a TCP socket on 127.0.0.1. A frame is only
ever decoded as JSON (never :erlang.binary_to_term/1), and every request carries the
server's token, compared in constant time.
Requests (client to server), {"v": 1, "token", "request", ...}:
runandcheck-argv(the task's arguments) andenv(the client'sJUGGERNAUT_*variables, values) andenv_names(the names of the client's other non-empty variables, for therefuse_envcheck; their values never leave the client);statusandstop.
Replies (server to client), one or more frames:
{"queued": n}- the request waits,njobs ahead of it, sent again as the queue moves;{"queued": 0}comes once, when the job starts;{"out": "stdout" | "stderr", "data": text}- output of the job, in order;{"exit": code}- the job's exit code, the last frame;{"status": {...}}- the answer tostatus;{"error": message, "exit": code}- a refused request (bad token, bad frame).
Summary
Functions
The environment a client sends: the values of its JUGGERNAUT_* variables and the names
of its other non-empty variables (never their values).
Decodes a reply frame ({:error, message} for one that is not a JSON object).
Decodes a request frame and checks its token against token. Returns the request, or
{:error, message} for a frame that is not JSON, has another version, a wrong token or
an unknown request.
Encodes a frame (a map) as JSON.
A request frame: request with its fields and the token.
The socket options of both ends.
Types
Functions
The environment a client sends: the values of its JUGGERNAUT_* variables and the names
of its other non-empty variables (never their values).
Decodes a reply frame ({:error, message} for one that is not a JSON object).
Decodes a request frame and checks its token against token. Returns the request, or
{:error, message} for a frame that is not JSON, has another version, a wrong token or
an unknown request.
Encodes a frame (a map) as JSON.
A request frame: request with its fields and the token.
@spec socket_opts() :: [:gen_tcp.option()]
The socket options of both ends.