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 ¶
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 ¶
LoadFresh returns the cached replica set for (host, repoPath) if one exists and is fresh, otherwise nil.
func Persist ¶
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 ¶
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.