hops

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 7 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 hops keeps the local log of completed moves (state/hops.jsonl): which session went from which machine to this one, and whether the copy left behind has been marked as moved. A mark that could not be written yet (the old session was still running) is "pending" and is written by a later scan once that session has stopped.

Index

Constants

View Source
const (
	MarkDone    = "done"    // the old copy carries "↪ moved to …"
	MarkPending = "pending" // write it once the old session has stopped
	MarkOff     = "off"     // not wanted (fork, or the user turned it off)
	MarkFailed  = "failed"  // gave up (see MarkError)
	// MarkDiverged: the old copy gained new turns after the move, so it is not marked;
	// both copies exist and hopsesh shows them as diverged.
	MarkDiverged = "diverged"
)

Mark states for the copy left behind.

Variables

This section is empty.

Functions

func Append

func Append(stateDir string, h Hop) error

Append records a hop.

func Update

func Update(stateDir, sessionID, from string, change func(*Hop)) error

Update changes the newest hop of a session from a machine and rewrites the log atomically.

Types

type Hop

type Hop struct {
	Time       time.Time `json:"time"`
	SessionID  string    `json:"sessionId"`
	Title      string    `json:"title"`
	From       string    `json:"from"` // machine name the copy came from
	To         string    `json:"to"`   // this machine's name
	Fork       bool      `json:"fork,omitempty"`
	Notified   bool      `json:"notified,omitempty"` // the old session was told about the move
	SourceFile string    `json:"sourceFile"`
	Mark       string    `json:"mark"`
	MarkError  string    `json:"markError,omitempty"`
	Tries      int       `json:"tries,omitempty"`
}

Hop is one completed move to this machine.

func Last

func Last(stateDir, sessionID string) (Hop, bool)

Last returns the newest hop of a session, if any.

func Load

func Load(stateDir string) []Hop

Load returns every recorded hop, oldest first.

func Pending

func Pending(stateDir, from string) []Hop

Pending returns hops from a machine whose old copy still needs its mark, newest first per session (an older pending hop of the same session is superseded).

Jump to

Keyboard shortcuts

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