replicas

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 5 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 replicas manages the on-disk cache of Entire data-plane replicas and the per-invocation NodeConfig that drives the transport's warm/cold paths.

A NodeConfig is built up front from the remote URL: the entry URL is derived from the cluster host, and the initial node list is whatever the local cache contains for (cluster, repo) — possibly empty on a cold invocation, in which case the transport's cold path probes the entry domain and populates the set from the first X-Entire-Replicas header it sees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractRepoPath

func ExtractRepoPath(urlPath string) string

ExtractRepoPath builds the per-repo cache key from a remote URL's path. The path is used verbatim (minus leading/trailing slashes), so /et/<project>/<repo> (or legacy /git/<owner>/<repo>) and /gh/<owner>/<repo> live in distinct keyspaces — they're separate repos with potentially-different replica sets, even when the segments after the prefix match.

entire://host/et/project/repo -> "et/project/repo" entire://host/gh/owner/repo -> "gh/owner/repo"

func Invalidate

func Invalidate(host, repoPath string)

Invalidate removes the cached entry for (host, repoPath). Best effort: failures are logged but never fatal. Runs under ModifyCache's lock so it doesn't race a concurrent Persist.

func LoadFresh

func LoadFresh(host, repoPath string) []string

LoadFresh returns the cached replica set for (host, repoPath) if one exists and is fresh, otherwise nil.

func Persist

func Persist(host, repoPath string, nodes []string)

Persist stores the given replica set in the on-disk cache. Best effort: cache write failures are logged but never fatal. The load-mutate-save runs under ModifyCache's single lock so concurrent clone/fetch/push processes don't clobber each other's entries.

Every info/refs response carries the replica set, so most calls find it already cached. Those skip the write, and with it the exclusive lock every other git operation on this machine needs, unless the entry is in the second half of its TTL.

The skip check reads the cache without the lock. An Invalidate that lands between that read and the return leaves the entry deleted, so the next operation rediscovers the replicas; it never caches a wrong set. One extra discovery is the price of not locking on every call.

Types

type NodeConfig

type NodeConfig struct {
	InitialNodes []string
	EntryURL     string
	ClusterHost  string
	RepoPath     string
}

NodeConfig is the discovery-time state the transport needs: an entry-domain URL to use when the cached replica set is empty or exhausted, whatever replicas are currently cached, the cluster host for same-cluster redirect checks, and the repo path used as the cache key (empty when the URL has no path, in which case caching is disabled).

func Resolve

func Resolve(parsedURL *url.URL) NodeConfig

Resolve builds the NodeConfig for this invocation. No network operations: the entry URL is derived from the cluster host in the remote URL and the initial node list is whatever the local replica cache contains.

func (NodeConfig) Caching

func (n NodeConfig) Caching() bool

Caching reports whether this config participates in the persistent replica cache. False when the URL had no recognisable repo path to key on.

Jump to

Keyboard shortcuts

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