Documentation
¶
Overview ¶
Package peer is how hopsesh on two machines work together over one SSH connection: `hopsesh peer --stdio` on the other machine answers requests, one JSON object per line each way. Both ends must speak the same Protocol; a mismatch is refused, never bridged.
Index ¶
Constants ¶
const ( MethodHello = "hello" MethodPlan = "plan" // plan receiving a pushed session (nothing changes) MethodApply = "apply" // carry out the plan made on this connection MethodUndo = "undo" )
Methods.
const ( CodeProtocol = "protocol" // the two ends speak different protocols CodeRefused = "refused" // the machine does not receive sessions CodeFailed = "failed" )
Error codes.
const Protocol = 1
Protocol is the version of the messages below. Any change to them changes it.
Variables ¶
var ( ErrProtocol = errors.New("hopsesh on the two machines speak different protocols") ErrRefused = errors.New("that machine does not receive sessions") )
ErrProtocol and ErrRefused classify an Error with errors.Is.
Functions ¶
Types ¶
type AgentInfo ¶
type AgentInfo struct {
ID agent.ID `json:"id"`
Name string `json:"name"`
Version string `json:"version,omitempty"`
Present bool `json:"present"` // has its data folder there
Write bool `json:"write"` // hopsesh can write its sessions (continue into it)
}
AgentInfo is an agent on the peer.
type ApplyReply ¶
type ApplyReply struct {
Result *move.Result `json:"result"`
Writes []host.SnapshotWrite `json:"writes,omitempty"`
Journal string `json:"journal"` // the peer's undo id
}
ApplyReply is what the peer did, and what the sender must do on its side: the writes meant for its copy (marks, lineage), and a mark owed once its open copy ends.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls a peer, one request at a time.
type Hello ¶
type Hello struct {
Protocol int `json:"protocol"`
Version string `json:"version"` // the sender's hopsesh
From string `json:"from"` // the sender's machine name
}
Hello opens a conversation.
type HelloReply ¶
type HelloReply struct {
Protocol int `json:"protocol"`
Version string `json:"version"`
Machine string `json:"machine"`
OS string `json:"os"`
Receive bool `json:"receive"` // it accepts pushed sessions
Agents []AgentInfo `json:"agents"`
}
HelloReply describes the peer.
type Package ¶
type Package struct {
Location string `json:"location"` // the sender's machine name
Facts host.Facts `json:"facts"`
Agent agent.ID `json:"agent"`
Install agent.Install `json:"install"`
Session agent.Summary `json:"session"`
Live agent.LiveInfo `json:"live"`
Git *repos.GitState `json:"git,omitempty"`
Lineage *lineage.Manifest `json:"lineage,omitempty"`
Account *agent.Account `json:"account,omitempty"`
Files []host.SnapshotFile `json:"files"`
}
Package is one session sent to a peer: its files and what the sender knows about it. Nothing else of the sender's machine is reachable from the peer.
type PlanRequest ¶
type PlanRequest struct {
Package Package `json:"package"`
Target agent.ID `json:"target,omitempty"`
Options move.Options `json:"options"`
}
PlanRequest asks a peer to plan receiving a package, in its own agent or another.
type UndoRequest ¶
type UndoRequest struct {
Journal string `json:"journal"`
Force bool `json:"force,omitempty"` // undo even what was used since
}
UndoRequest asks a peer to undo one of its journals.