package fetch

Import Path
	golang.org/x/pkgsite/internal/fetch (on go.dev)

Dependency Relation
	imports 40 packages, and imported by 5 packages

Involved Source Files Package fetch provides a way to fetch modules from a proxy. fetchlocal.go latest.go limit.go Package fetch provides a way to fetch modules from a proxy. loadshedding.go Package fetch provides a way to fetch modules from a proxy. Package fetch provides a way to fetch modules from a proxy. unit.go
Package-Level Type Names (total 6, in which 4 are exported)
/* sort exporteds by: | */
BadPackageError represents an error loading a package because its contents do not make up a valid package. This can happen, for example, if the .go files fail to parse or declare different package names. Err error (*T) Error() string *T : error
Error error Finish time.Time ModulePath string Start time.Time Status int Version string ZipSize uint64 func FetchInfos() []*FetchInfo
// caller must defer this on all code paths Error error GoModPath string HasGoMod says whether the zip contain a go.mod file. If Module (below) is non-nil, then Module.HasGoMod will be the same value. But HasGoMod will be populated even if Module is nil because there were problems with it, as long as we can download and read the zip. MainVersion string MasterVersion string Module *internal.Module ModulePath string PackageVersionStates []*internal.PackageVersionState RequestedVersion string ResolvedVersion string Status int func FetchLocalModule(ctx context.Context, modulePath, localPath string, sourceClient *source.Client) *FetchResult func FetchModule(ctx context.Context, modulePath, requestedVersion string, proxyClient *proxy.Client, sourceClient *source.Client) (fr *FetchResult)
LoadShedStats holds statistics about load shedding. MaxSizeInFlight uint64 RequestsInFlight int RequestsShed int RequestsTotal int SizeInFlight uint64 func ZipLoadShedStats() LoadShedStats
Package-Level Functions (total 34, in which 6 are exported)
FetchInfos returns information about all fetches in progress, sorted by start time.
FetchLocalModule fetches a module from a local directory and process its contents to return an internal.Module and other related information. modulePath is not necessary if the module has a go.mod file, but if both exist, then they must match. FetchResult.Error should be checked to verify that the fetch succeeded. Even if the error is non-nil the result may contain useful data.
FetchModule queries the proxy or the Go repo for the requested module version, downloads the module zip, and processes the contents to return an *internal.Module and related information. Even if err is non-nil, the result may contain useful information, like the go.mod path. Callers of FetchModule must defer fr.Defer() immediately after the call.
GetInfo returns the result of a request to the proxy .info endpoint. If the modulePath is "std", a request to @master will return an empty commit time.
LatestModuleVersions uses the proxy to get information about the latest versions of modulePath. It returns a LatestModuleVersions whose RawVersion and CookedVersion is obtained from the proxy @v/list and @latest endpoints. The cooked version is computed by choosing the latest version after removing versions that are retracted in the go.mod file of the raw version. The GoodVersion of LatestModuleVersions is not set. It should be determined when inserting into a data source, since it depends on the contents of the data source. The hasGoMod function that is passed in should check if version v of the module has a go.mod file, using a source other than the proxy (e.g. a database). If it doesn't have enough information to decide, it should return an error that wraps derrors.NotFound. If a module has no tagged versions and hasn't been accessed at a pseudo-version in a while, then the proxy's list endpoint will serve nothing and its @latest endpoint will return a 404/410. (Example: cloud.google.com/go/compute/metadata, which has a v0.0.0-20181107005212-dafb9c8d8707 that @latest does not return.) That is not a failure, but a valid state in which there is no version information for a module, even though particular pseudo-versions of the module might exist. In this case, LatestModuleVersions returns (nil, nil). As a special case, the "std" module's versions are fetched from the repo (by calling stdlib.Versions). We assume stdlib versions are never retracted, and that there are no incompatible versions.
ZipLoadShedStats returns a snapshot of the current LoadShedStats for zip files.
Package-Level Variables (total 17, in which 7 are exported)
FetchLatencyDistribution aggregates frontend fetch request latency by status code. It does not count shedded requests.
FetchPackageCount counts how many packages were successfully fetched.
FetchResponseCount counts fetch responses by status.
Version and commit time are pre specified when fetching a local module, as these fields are normally obtained from a proxy.
Version and commit time are pre specified when fetching a local module, as these fields are normally obtained from a proxy.
SheddedFetchCount counts the number of fetches that were shedded.
Package-Level Constants (total 5, in which 1 are exported)
MaxFileSize is the maximum filesize that is allowed for reading. The fetch process should fail if it encounters a file exceeding this limit.