Expand description
A client of the webserver’s REST API (/api/v1), for the user CLI and the web UI.
Requests go through a Transport: HTTP in the real CLI (HttpTransport), something in
process in tests. Every request carries Schedr-Client-Version. Actions return a command;
Client::wait reads it back until the master has decided it (see archive/PROJECT.md, Web UI
and CLI: the CLI waits for the decision).
Re-exports§
pub use stream::Chunks;pub use stream::EventReader;pub use stream::ServerEvent;
Modules§
- stream
- Streamed answers: a response body read as it comes (
Chunks), and server-sent events read from one (EventReader), forGET /api/v1/changes. - times
- Times in the CLI: reading
--forand showing a moment in UTC and local time (see archive/PROJECT.md, Web UI and CLI: times and time zones).
Structs§
- ApiRequest
- A request to the API.
- ApiResponse
- The API’s answer.
- Client
- Typed calls to the API.
- Http
Transport - The API over HTTP.
- Router
Transport - The API in the same process: requests go straight to its router, with no network (the
web UI of
schedr standalone, and tests). - Timeouts
- How long the CLI and
schedr uiwait for a webserver, each aSCHEDR_HIDDEN__CLIENT__*timing (decision 493).
Enums§
- Auth
- Credentials the CLI sends (never validated here).
- Client
Error - Why a request failed.
- Method
- An HTTP method the client uses.
- Task
Action - What
schedr tasksasks of a task. - Worker
Action - What
schedr workers drain/resumeasks of a worker.
Constants§
- CLIENT_
VERSION_ HEADER - The header carrying this client’s version.
- COMMAND_
TRIES - How many times
Client::submitsends a command whose answer doesn’t come. - CONNECT_
TIMEOUT - How long connecting to the server may take.
- POLL_
INTERVAL - How often
Client::waitreads a command back. - REQUEST_
TIMEOUT - How long one request may take, from the start of the connection until the body ends.
- STREAM_
TIMEOUT - How long a stream may stay open before the client gives up on it (and opens another).
- VERSION
- This client’s version (the workspace’s), sent in
CLIENT_VERSION_HEADER. - WAIT_
TIMEOUT - How long
Client::waitwaits for the master’s decision.
Statics§
- COMMAND_
KEY - The key of the command sent in this scope (B140): sent as
Idempotency-Keywith eachPOST, so a command sent again with it after its answer was lost (the webserver may have stored it) is the one stored then, not a second. - USER
- The person a request is made for (the web UI sets it for each page it serves): sent
as
X-Schedr-User, which a webserver takes only from a caller proven to be the UI (seeschedr_api::auth).
Traits§
- Transport
- Sends requests to the API.
Functions§
- current_
user - The person the current request is made for, if
USERis set. - for_
same_ user workmade for the same person as the current request:USERdoesn’t follow a spawned task by itself, so a page asking several deployments at once carries it over.- new_
command_ key - A new command key: unique, for one command (see
Client::submit). - path_
segment segmentas one URL path segment: everything but letters, digits and-._~percent-encoded (a DAG ID may hold/,:and#).- with_
command_ key sendmade withkeyas its command’sIdempotency-Key(COMMAND_KEY).