Documentation
¶
Overview ¶
Package orgsync saves and shares an organization workspace with sync on (spec_053_enterprise EN-62 to EN-64): Blitz's service, not the window, runs it, so it goes on with the window closed. A change on disk starts a timer; a few seconds after the last one, and never while a turn runs in the workspace, everything is committed and pushed. Others' changes are fetched when it starts, when the watch stream names a commit, now and then, and before each push, and merged between turns. A file both changed keeps both versions: the other person's under its name, this person's beside it as "name (conflict, Ana).ext". Its state is said in words, never in Git's.
Index ¶
Constants ¶
const ( Saved = "saved" Saving = "saving" Offline = "offline" // its saves wait on this computer SignedOut = "signed_out" // sign in to sync Conflicts = "conflicts" // both versions kept // Refused is the service turning this person's saves down: it was // reached, so it isn't Offline; Err says why, in Git's words. Refused = "refused" // Secrets is a save held back on this computer: what it would send // holds what looks like an API key or another secret (Err names // where), and nothing goes until it's taken out. Secrets = "secrets" )
States of a workspace's sync (EN-64).
Variables ¶
var ErrBusy = errors.New("a turn is running in the workspace: its changes save when it ends")
ErrBusy is SaveNow while a turn runs: what the agent is changing saves when it ends.
var ErrNotRunning = errors.New("this workspace's sync isn't running")
ErrNotRunning is SaveNow before Run, or after it ended.
var ErrSignedOut = errors.New("signed out of the organization")
ErrSignedOut is what Git's failure means when Blitz isn't signed in to the organization: no credential for its host.
Functions ¶
Types ¶
type Git ¶
Git runs git with args in dir, with the organization's credential helper, and gives its output; a failure's error carries its output.
type State ¶
type State struct {
State string
// Pairs are the files with both versions kept: each the shared one and
// this person's copy beside it.
Pairs [][2]string
// Err is the last failure, in Git's words, for the log.
Err string
}
State is a workspace's sync now.
type Syncer ¶
type Syncer struct {
Dir string
Git Git
// Upstream is the Git remote that's the organization's ("origin"): a
// folder shared with it keeps its own origin.
Upstream string
// Who names the person in the saves' messages ("Ana").
Who string
// Busy reports whether a turn is running in the workspace now.
Busy func() bool
// SignedIn reports whether Blitz is signed in to the organization.
SignedIn func() bool
// Quiet is how long after the last change it saves (5 s); Poll how
// often it looks for changes (2 s); Fetch how often it fetches with no
// news from the watch stream (1 min).
Quiet, Poll, Fetch time.Duration
// Now is the clock (time.Now).
Now func() time.Time
// OnState hears each change of state.
OnState func(State)
// contains filtered or unexported fields
}
Syncer keeps one workspace in step.
func (*Syncer) Remote ¶
func (s *Syncer) Remote()
Remote says the watch stream named a commit: it's fetched and merged between turns.