syncer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 15 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 syncer runs a sync cycle: fetch the registry, resolve the developer's skills and apply them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prefs

func Prefs(cfg state.Config, lock state.Lock) policy.Prefs

Prefs returns the developer's choices plus the skills present on the machine.

Types

type Result

type Result struct {
	Skipped  bool // another sync is running, or the last one is too recent
	Commit   string
	Report   install.Report
	Warnings []string
}

Result describes a sync run.

type Syncer

type Syncer struct {
	Paths     paths.Paths
	Installer *install.Installer
	Now       func() time.Time
	// FetchTimeout bounds the registry fetch; when it expires the sync goes
	// on offline with the last fetched registry. Zero means no limit.
	FetchTimeout time.Duration
	// FetchBackoff skips the network for this long after a failed fetch, so
	// agent hooks do not wait on a dead network at every session start.
	FetchBackoff time.Duration
	// TrustLocalTags only fetches the pinned tags missing locally, without
	// checking whether known tags moved upstream: tags are immutable here,
	// so agent hooks skip that network round trip. Manual and timer syncs
	// leave it off and report moved tags.
	TrustLocalTags bool
	// NoFetch uses the registry as last fetched, e.g. right after init
	// fetched it.
	NoFetch bool
}

Syncer keeps the installed skills in line with the registry.

func New

func New(p paths.Paths) *Syncer

New returns a syncer for the given paths.

func (*Syncer) Lock

func (s *Syncer) Lock(ctx context.Context) (unlock func(), err error)

Lock waits for the sync lock, for commands that change the configuration and then sync: the change and the sync it triggers are never interleaved with a hook sync.

func (*Syncer) Store

func (s *Syncer) Store() *snapshot.Store

Store returns the registry snapshot store.

func (*Syncer) Sync

func (s *Syncer) Sync(ctx context.Context, force bool) (Result, error)

Sync runs a cycle. Unless force is set, it does nothing if the last sync is more recent than the configured debounce window. It is skipped if another sync holds the lock.

func (*Syncer) SyncLocked

func (s *Syncer) SyncLocked(ctx context.Context, force bool) (Result, error)

SyncLocked runs a cycle; the caller holds the sync lock.

Jump to

Keyboard shortcuts

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