orgsync

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 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 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

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

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

View Source
var ErrNotRunning = errors.New("this workspace's sync isn't running")

ErrNotRunning is SaveNow before Run, or after it ended.

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

func Failed added in v0.9.1

func Failed(state string) bool

Failed is whether a sync's state means the service hasn't got this computer's saves: Offline, SignedOut, Refused or Secrets. The service says so with the state (GetOrgSync's failed), so the clients needn't keep their own list.

Types

type Git

type Git func(ctx context.Context, dir string, args ...string) ([]byte, error)

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.

func (*Syncer) Run

func (s *Syncer) Run(ctx context.Context)

Run keeps the workspace in step until ctx ends.

func (*Syncer) SaveNow

func (s *Syncer) SaveNow(ctx context.Context) (State, error)

SaveNow saves what's changed and sends what's waiting at once, rather than after the quiet spell or the next minute's try, taking others' changes first, and is the state after.

func (*Syncer) State

func (s *Syncer) State() State

State is the sync's state now.

Jump to

Keyboard shortcuts

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