Documentation
¶
Overview ¶
Package versionfetch provides concurrent helpers for checking the latest versions of installed agents against their package registries.
Index ¶
Constants ¶
const DefaultConcurrency = 8
DefaultConcurrency is the default number of parallel version-check workers.
Variables ¶
This section is empty.
Functions ¶
func CheckLatestVersions ¶
func CheckLatestVersions( ctx context.Context, fetcher LatestVersionFetcher, installations []*agent.Installation, agentDefs map[string]catalog.AgentDef, concurrency int, ) []error
CheckLatestVersions fills installations[i].LatestVersion concurrently by consulting the registry-appropriate provider via fetcher.GetLatestVersion.
The returned errors slice is parallel to installations: errs[i] holds the error (if any) encountered for installations[i]. Installations without a matching agent definition or install method are skipped (nil entry).
If concurrency <= 0, DefaultConcurrency is used.
Results are written back into installations by index, so the caller's slice retains stable ordering and there are no data races on the slice header.
func NonNilErrors ¶
NonNilErrors filters the parallel error slice returned by CheckLatestVersions to just the entries that actually failed. Preserves order.
Types ¶
type LatestVersionFetcher ¶
type LatestVersionFetcher interface {
GetLatestVersion(ctx context.Context, method catalog.InstallMethodDef) (agent.Version, error)
}
LatestVersionFetcher is the subset of installer.Manager used by CheckLatestVersions. Accepting an interface keeps the helper decoupled from the concrete manager and makes it straightforward to unit test.