Skip to main content

Module remote

Module remote 

Source
Expand description

Workspaces on other machines: Remote, one machine reached through a transport, and Hosts, which sends each path written HOST:PATH to that host’s Remote and every other path to the workspace it wraps.

A transport is a command that runs its last argument, a shell line, on the other machine with the remote user’s shell in their home, forwards its stdin, keeps its stdout and stderr apart, ends with its exit status, and ends with 255 when the transport itself failed: ssh does, and so does koh exec. Every file operation is one short sh script run that way, at most CALLS_PER_HOST at once, and every process a local transport process running the command there.

use std::path::Path;
use std::sync::Arc;
use rig_tools::process::Launcher;
use rig_tools::remote::{Hosts, Remote};
use rig_tools::workspace::{Local, Workspace};

let bench = ["koh", "exec", "bench", "--sh"];
let dev = ["ssh", "-o", "BatchMode=yes", "dev@box"];
let hosts = Hosts::new(
    Arc::new(Local),
    [
        Remote::new("bench", bench, Launcher::default())?,
        Remote::new("box", dev, Launcher::default())?,
    ],
);
let text = hosts.read(Path::new("bench:~/strata/src/lib.rs"), 4096)?;

Structs§

Hosts
A workspace (the inner one, such as Local) whose paths written HOST:PATH, HOST the name of one of its Remotes, are that host’s PATH, as scp reads them: bench:~/strata/src/lib.rs, bench:/srv/app. Every other path is the inner workspace’s. Every path it gives back for a remote file (canonical, files) keeps the HOST: form, so the facts and footprints the tools make of them can be passed back as they are; a relative path joined onto a HOST: base stays there.
Remote
Another machine, reached through a transport (see the module docs). Its paths are that machine’s: absolute, or under ~, its user’s home; a relative path is relative to that home, where the transport starts. Paths are folded without asking the machine (canonical), so links there are not followed.

Constants§

CALLS_PER_HOST
How many file operations run on one host at once; the rest wait for a turn. Each is a connection of its own, and a server may drop some of a burst of new connections from one client, as one that takes only two handshakes from a client at a time does.
TRANSPORT_FAILED
The exit status with which a transport says it failed, as ssh does.