Skip to main content

Crate schedr_client

Crate schedr_client 

Source
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), for GET /api/v1/changes.
times
Times in the CLI: reading --for and 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.
HttpTransport
The API over HTTP.
RouterTransport
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 ui wait for a webserver, each a SCHEDR_HIDDEN__CLIENT__* timing (decision 493).

Enums§

Auth
Credentials the CLI sends (never validated here).
ClientError
Why a request failed.
Method
An HTTP method the client uses.
TaskAction
What schedr tasks asks of a task.
WorkerAction
What schedr workers drain / resume asks of a worker.

Constants§

CLIENT_VERSION_HEADER
The header carrying this client’s version.
COMMAND_TRIES
How many times Client::submit sends a command whose answer doesn’t come.
CONNECT_TIMEOUT
How long connecting to the server may take.
POLL_INTERVAL
How often Client::wait reads 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::wait waits for the master’s decision.

Statics§

COMMAND_KEY
The key of the command sent in this scope (B140): sent as Idempotency-Key with each POST, 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 (see schedr_api::auth).

Traits§

Transport
Sends requests to the API.

Functions§

current_user
The person the current request is made for, if USER is set.
for_same_user
work made for the same person as the current request: USER doesn’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
segment as one URL path segment: everything but letters, digits and -._~ percent-encoded (a DAG ID may hold /, : and #).
with_command_key
send made with key as its command’s Idempotency-Key (COMMAND_KEY).