replicas

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 4 Imported by: 0

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.

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