Involved Source Filesfetch.gomemory.gometrics.gopages.go
Package worker provides functionality for running a worker service.
Its primary operation is to fetch modules from a proxy and write them to the
database.
Package-Level Type Names (total 8, in which 3 are exported)
/* sort exporteds by: | */
A Fetcher holds state for fetching modules.
Cache*cache.CacheDB*postgres.DBProxyClient*proxy.ClientSourceClient*source.Client
FetchAndUpdateLatest fetches information about the latest versions from the proxy,
and updates the database if the version has changed.
It returns the most recent good information, which may be what it just fetched or
may be what is already in the DB.
It does not update the latest good version; that happens inside InsertModule, because
it must be protected by the module-path advisory lock.
FetchAndUpdateState fetches and processes a module version, and then updates
the module_version_states table according to the result. It returns an HTTP
status code representing the result of the fetch operation, and a non-nil
error if this status code is not 200.
fetchAndInsertModule fetches the given module version from the module proxy
or (in the case of the standard library) from the Go repo and writes the
resulting data to the database.
invalidateCache deletes the series path for modulePath, as well as any
possible URL path of which it is a componentwise prefix. That is, it deletes
example.com/mod, example.com/mod@v1.2.3 and example.com/mod/pkg, but not the
unrelated example.com/module.
We delete the series path, not the module path, because adding a v2 module
can affect v1 pages. For example, the first v2 module will add a "higher
major version" banner to all v1 pages. While adding a v1 version won't
currently affect v2 pages, that could change some day (for instance, if we
decide to provide history). So it's better to be safe and delete all paths in
the series.
processMemStats holds values that describe the current process's memory.
All values are in bytes.
// resident set size (physical memory in use)
// virtual memory size
func getProcessMemStats() (processMemStats, error)
Read memory information for the current cgroup.
(A cgroup is the sandbox in which a docker container runs.)
All values are in bytes.
Returns nil on any error.
parseLimitParam parses the query parameter "limit" as an integer. If the
parameter is missing or there is a parse error, it is logged and the default
value is returned.
parseModulePathAndVersion returns the module and version specified by p. p
is assumed to have either of the following two structures:
- <module>/@v/<version>
- <module>/@latest
(this is symmetric with the proxy url scheme)
Parse the template for the status page.
percentage computes the truncated percentage of x/y.
It returns 0 if y is 0.
x and y can be any int or uint type.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.