link

package
v1.0.0-alpha1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const Protocol = "cybershuttle.v1"

Protocol is the WebSocket subprotocol Linkspan offers and the link endpoint selects.

View Source
const TokenPrefix = "link."

TokenPrefix marks the subprotocol that carries the link token.

Variables

View Source
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 Host

func Host(processID string, port uint16) string

Host is the address Transport dials to reach port on the process's job.

func OfferedToken

func OfferedToken(r *http.Request) string

OfferedToken returns the link token among the subprotocols a WebSocket upgrade offered, or "".

func Ports

func Ports(processID string) (control, jupyter uint16)

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.

func (*Issued) Env

func (i *Issued) Env() map[string]string

Env is the job environment that carries Issued, under the names Linkspan reads (LINKSPAN_LINK_TOKEN, JUPYTER_TOKEN) and the ones its documented job script uses (CS_LINK_URL, CS_CONTROL_PORT), plus CS_JUPYTER_PORT for the workflow's addr.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds the live link of each process.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) Dial

func (r *Registry) Dial(ctx context.Context, processID string, port uint16) (net.Conn, error)

Dial opens a stream to the server the process's job runs on loopback port.

func (*Registry) Linked

func (r *Registry) Linked(processID string) bool

Linked reports whether the process currently holds a link.

func (*Registry) Serve

func (r *Registry) Serve(ctx context.Context, processID string, conn net.Conn) error

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.

func (*Registry) Transport

func (r *Registry) Transport() *http.Transport

Transport returns an HTTP transport whose connections are streams over the links, for addresses made by Host. It pools them per process and port, and carries WebSocket upgrades, so a reverse proxy over it serves a Jupyter Server whole.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL