Documentation
¶
Overview ¶
Package mirror provides selective package mirroring for pre-populating the proxy cache.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct {
ID string `json:"id"`
State JobState `json:"state"`
Progress Progress `json:"progress"`
CreatedAt time.Time `json:"created_at"`
Error string `json:"error,omitempty"`
// contains filtered or unexported fields
}
Job represents an async mirror operation.
type JobRequest ¶
type JobRequest struct {
PURLs []string `json:"purls,omitempty"`
Registry string `json:"registry,omitempty"`
}
JobRequest is the JSON body for starting a mirror job via the API.
type JobStore ¶
type JobStore struct {
// contains filtered or unexported fields
}
JobStore manages in-memory mirror jobs.
func NewJobStore ¶
NewJobStore creates a new job store. The parent context is used as the base for all job contexts so that jobs are canceled when the server shuts down.
func (*JobStore) Cleanup ¶
func (js *JobStore) Cleanup()
Cleanup removes completed/failed/canceled jobs older than jobTTL.
func (*JobStore) Create ¶
func (js *JobStore) Create(req JobRequest) (string, error)
Create starts a new mirror job and returns its ID.
func (*JobStore) Get ¶
Get returns a snapshot of a job by ID. The returned copy is safe to serialize without holding the lock.
func (*JobStore) StartCleanup ¶
StartCleanup runs periodic cleanup of old jobs until the context is canceled.
type Mirror ¶
type Mirror struct {
// contains filtered or unexported fields
}
Mirror pre-populates the proxy cache from various input sources.
func New ¶
func New(proxy *handler.Proxy, db *database.DB, store storage.Storage, logger *slog.Logger, workers int) *Mirror
New creates a new Mirror with the given dependencies.
func (*Mirror) Run ¶
func (m *Mirror) Run(ctx context.Context, source Source, onProgress ...ProgressFunc) (*Progress, error)
Run mirrors all packages from the source using a bounded worker pool. It returns the final progress when complete. If onProgress is non-nil, it is called with progress snapshots as work proceeds.
type MirrorError ¶
type MirrorError struct {
Ecosystem string `json:"ecosystem"`
Name string `json:"name"`
Version string `json:"version"`
Error string `json:"error"`
}
MirrorError records a single failed mirror attempt.
type PURLSource ¶
type PURLSource struct {
PURLs []string
RegClient *registries.Client
}
PURLSource yields packages from PURL strings. Versioned PURLs produce a single item. Unversioned PURLs look up all versions from the registry.
func (*PURLSource) Enumerate ¶
func (s *PURLSource) Enumerate(ctx context.Context, fn func(PackageVersion) error) error
type PackageVersion ¶
PackageVersion identifies a specific package version to mirror.
func (PackageVersion) String ¶
func (pv PackageVersion) String() string
type Progress ¶
type Progress struct {
Total int64 `json:"total"`
Completed int64 `json:"completed"`
Skipped int64 `json:"skipped"`
Failed int64 `json:"failed"`
Bytes int64 `json:"bytes"`
Errors []MirrorError `json:"errors,omitempty"`
StartedAt time.Time `json:"started_at"`
Phase string `json:"phase"`
}
Progress tracks the state of a mirror operation.
type ProgressFunc ¶
type ProgressFunc func(Progress)
ProgressFunc is called periodically with a snapshot of the current progress.
type RegistrySource ¶
type RegistrySource struct {
Ecosystem string
}
RegistrySource enumerates all packages in a registry for full mirroring. Registry enumeration is not yet implemented for any ecosystem.
func (*RegistrySource) Enumerate ¶
func (s *RegistrySource) Enumerate(_ context.Context, _ func(PackageVersion) error) error
type SBOMSource ¶
type SBOMSource struct {
Path string
RegClient *registries.Client
}
SBOMSource extracts package versions from a CycloneDX or SPDX SBOM file.
func (*SBOMSource) Enumerate ¶
func (s *SBOMSource) Enumerate(ctx context.Context, fn func(PackageVersion) error) error