syncer

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 2 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 is the seam between the mirror and the work that needs git and a disk. The mirror owns it. gitsyncer runs the git binary over a cache of clones, and fakesyncer keeps a commit graph in memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PlanChunks

func PlanChunks(n int, fits func(from, to int) bool) []int

PlanChunks splits n commits into pushes. It returns the index of the last commit of each push, in order. fits(from, to) says whether the objects of commit to that commit from does not reach (from -1 means none) fit in one push. A commit that does not fit alone is still a push of its own.

Types

type CacheState

type CacheState struct {
	Bytes      int64
	OverBudget bool
}

type Endpoint

type Endpoint struct {
	URL  string
	Cred gitremote.Cred
}

type LocalError

type LocalError struct{ Err error }

func (*LocalError) Error

func (e *LocalError) Error() string

func (*LocalError) Unwrap

func (e *LocalError) Unwrap() error

type PushRequest

type PushRequest struct {
	Repo   string
	Source Source
	Remote Endpoint
	Specs  []gitremote.PushSpec
}

PushRequest asks for the push of the specs from the clone of Repo to Remote. The clone gets the commits of the specs from Source when it lacks them.

type PushSourceRequest

type PushSourceRequest struct {
	Repo   string
	Target Endpoint
	Origin Endpoint
	Specs  []gitremote.PushSpec
}

PushSourceRequest asks for the push of the specs from the clone of Repo to Target. A commit that the clone lacks comes from Origin, by the ref of its spec. A delete needs no Origin.

type Result

type Result struct {
	Outcome gitremote.Outcome
	Err     error
}

Result is the result of one spec of a Push. Err is set when the spec was not pushed: a *SourceError for a commit that could not be fetched, or the failure of the call that the spec shared with the others. Every spec of a call has a Result.

type SeedLimits

type SeedLimits struct {
	Objects  int
	Packed   int64
	Inflated int64
}

type SeedPlanRequest

type SeedPlanRequest struct {
	Repo       string
	Remote     Endpoint
	Patterns   []string
	TargetRefs map[string]string
	Limits     SeedLimits
}

SeedPlanRequest asks for the pushes that copy the refs of Remote that Patterns match into a store whose refs are TargetRefs (stored name to commit).

type SeedPush

type SeedPush struct {
	Stored string
	Git    string
	Lease  string
	Commit string
}

type Source

type Source struct {
	URL  string
	Cred func(ctx context.Context) (gitremote.Cred, error)
}

Source is where the commits come from. Cred is called only when a fetch is needed, so a push of deletes mints no credential.

type SourceError

type SourceError struct {
	Err       error
	Transport bool
}

SourceError is a failure to get commits from the source. Transport is true when the network or the source failed, and false when the clone did.

func (*SourceError) Error

func (e *SourceError) Error() string

func (*SourceError) Unwrap

func (e *SourceError) Unwrap() error

type Syncer

type Syncer interface {
	Push(ctx context.Context, req PushRequest) (map[string]Result, error)
	PushSource(ctx context.Context, req PushSourceRequest) (map[string]gitremote.Outcome, error)
	SeedPlan(ctx context.Context, req SeedPlanRequest) ([]SeedPush, error)
	Trim(ctx context.Context) (CacheState, error)
}

Syncer does the work that needs git and a disk. Each call needs nothing from an earlier call, and no call names a path: the clone of a repository is private to the implementation.

Directories

Path Synopsis
Package fakesyncer is a syncer.Syncer over an in-memory commit graph.
Package fakesyncer is a syncer.Syncer over an in-memory commit graph.
Package gitsyncer is the syncer.Syncer that runs the git binary over a cache of bare clones on the local disk.
Package gitsyncer is the syncer.Syncer that runs the git binary over a cache of bare clones on the local disk.
Package syncertest is the conformance suite of syncer.Syncer.
Package syncertest is the conformance suite of syncer.Syncer.

Jump to

Keyboard shortcuts

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