Documentation
¶
Overview ¶
Package link holds the WebSockets Linkspan dials back to Airavata and reaches a job's servers through them.
It speaks Linkspan's link protocol, the one cs-plane defined (https://github.com/cyber-shuttle/linkspan/blob/main/docs/COMPATIBILITY.md): one WebSocket per job, offering the subprotocols cybershuttle.v1 and link.<token> and carrying yamux in binary frames, with Airavata as the yamux client. For each stream Airavata writes the target port as two big-endian bytes; Linkspan answers 1 when it connected to a server it runs on that loopback port, else 0, and then carries bytes until either end closes. yamux's keepalive detects a dead link, and Linkspan redials.
The registry is process-local. When Airavata restarts, every Linkspan redials.
Index ¶
Constants ¶
const Protocol = "cybershuttle.v1"
Protocol is the WebSocket subprotocol Linkspan offers and the link endpoint selects.
const TokenPrefix = "link."
TokenPrefix marks the subprotocol that carries the link token.
Variables ¶
var ErrNotLinked = errors.New("the process's Linkspan is not linked to Airavata")
ErrNotLinked reports a process whose Linkspan holds no link to this server.
Functions ¶
func OfferedToken ¶
OfferedToken returns the link token among the subprotocols a WebSocket upgrade offered, or "".
func Ports ¶
Ports derives the loopback ports a process's job serves on: Linkspan's control API and, one above it, the Jupyter Server. They are a function of the process id, in 20000–39999, so Airavata knows them before the job starts. A job sharing a node with another that drew the same port fails to start its server, as with any fixed port.
Types ¶
type Issued ¶
type Issued struct {
URL string
LinkToken string
JupyterToken string
ControlPort uint16
JupyterPort uint16
}
Issued is what a process's job is handed so its Linkspan can link: where to dial, the token to offer, and the ports and Jupyter token its servers use.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds the live link of each process.
func (*Registry) Serve ¶
Serve runs conn, the WebSocket a process's Linkspan opened, as that process's link until it ends or ctx is done. A newer link replaces an older one: the older is closed, since only one job of the process holds valid tokens at a time and a redialling Linkspan should not be refused by its own stale socket.