indexer

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTargetMissing = errors.New("target commit unavailable")

Functions

func EnoughFreeSpace

func EnoughFreeSpace(path string, minBytes uint64) (bool, error)

func RepositoryTooLarge

func RepositoryTooLarge(sizeBytes, maxBytes int64) bool

Types

type ActiveJobs

type ActiveJobs map[int64]struct{}

type ArchiveDownloader

type ArchiveDownloader interface {
	DownloadArchive(context.Context, string, string, string, string) (io.ReadCloser, error)
}

type ArchiveLimits

type ArchiveLimits struct {
	MaxDownloadBytes, MaxExtractedBytes, MaxFileBytes int64
	MaxFiles, MaxPathBytes                            int
}

type ArchiveSnapshotProvider

type ArchiveSnapshotProvider struct {
	Client        ArchiveDownloader
	WorkspacesDir string
	Limits        ArchiveLimits
	Metrics       *observability.Metrics
}

func (ArchiveSnapshotProvider) Cleanup

func (provider ArchiveSnapshotProvider) Cleanup(_ context.Context, snapshot Snapshot) error

func (ArchiveSnapshotProvider) CleanupStale

func (provider ArchiveSnapshotProvider) CleanupStale(ctx context.Context, active ActiveJobs) error

func (ArchiveSnapshotProvider) FreeSpacePath

func (provider ArchiveSnapshotProvider) FreeSpacePath() string

func (ArchiveSnapshotProvider) Prepare

func (provider ArchiveSnapshotProvider) Prepare(ctx context.Context, request SnapshotRequest) (snapshot Snapshot, err error)

type Enricher

type Enricher interface {
	Enrich(context.Context, Snapshot, repository.Repository, string) (EnrichmentStatus, error)
}

type EnrichmentStatus

type EnrichmentStatus = postgres.EnrichmentStatus

type Git

type Git struct {
	Binary, BaseURL, AskPass, CABundle, MirrorsDir, WorktreesDir string
	Runner                                                       Runner
	CommandTimeout                                               time.Duration
}

func (*Git) Cleanup

func (git *Git) Cleanup(ctx context.Context, repositoryID, jobID int64) error

func (*Git) Prepare

func (git *Git) Prepare(ctx context.Context, repo repository.Repository, job postgres.IndexJob, token string) (string, string, error)

func (*Git) PrepareCommit

func (git *Git) PrepareCommit(ctx context.Context, repo repository.Repository, jobID int64, targetSHA, token string) (string, string, error)

func (*Git) Prune

func (git *Git) Prune(ctx context.Context, active map[int64]struct{}) error

type GitSnapshotProvider

type GitSnapshotProvider struct{ Git *Git }

func (GitSnapshotProvider) Cleanup

func (provider GitSnapshotProvider) Cleanup(ctx context.Context, snapshot Snapshot) error

func (GitSnapshotProvider) CleanupStale

func (provider GitSnapshotProvider) CleanupStale(ctx context.Context, active ActiveJobs) error

func (GitSnapshotProvider) FreeSpacePath

func (provider GitSnapshotProvider) FreeSpacePath() string

func (GitSnapshotProvider) Prepare

func (provider GitSnapshotProvider) Prepare(ctx context.Context, request SnapshotRequest) (Snapshot, error)

type IndexPublisher

type IndexPublisher interface {
	Index(context.Context, repository.Repository, string) error
	WaitVisible(context.Context, uint32, string, string) error
}

type IndexStore

type IndexStore interface {
	RepositoryForIndex(context.Context, int64) (repository.Repository, error)
	DesiredSHA(context.Context, int64) (string, error)
}

type JobQueue

type JobQueue interface {
	ClaimIndex(context.Context, string) (postgres.IndexJob, error)
	RenewLease(context.Context, int64, string) error
	PublishIndex(context.Context, int64, string) error
	CompleteIndex(context.Context, int64, string, ...postgres.EnrichmentStatus) error
	FailIndex(context.Context, int64, string, string, bool) error
	ActiveJobIDs(context.Context) (map[int64]struct{}, error)
}

type Runner

type Runner struct {
	MaxOutput int64
	KillGrace time.Duration
	Capture   io.Writer
}

func (Runner) Output

func (runner Runner) Output(ctx context.Context, binary string, args, environment []string, directory string) ([]byte, error)

func (Runner) Run

func (runner Runner) Run(ctx context.Context, binary string, args, environment []string, directory string) error

type Snapshot

type Snapshot struct {
	Root         string
	RepositoryID int64
	JobID        int64
	CommitSHA    string
}

type SnapshotProvider

type SnapshotProvider interface {
	Prepare(context.Context, SnapshotRequest) (Snapshot, error)
	Cleanup(context.Context, Snapshot) error
	CleanupStale(context.Context, ActiveJobs) error
	FreeSpacePath() string
}

type SnapshotRequest

type SnapshotRequest struct {
	RepositoryID int64
	Repository   repository.Repository
	JobID        int64
	CommitSHA    string
	AccessToken  string
}

type TokenSource

type TokenSource interface {
	InstallationToken(context.Context, int64, []int64) (githubapp.Token, error)
}

type Worker

type Worker struct {
	ID                 string
	Queue              JobQueue
	Store              IndexStore
	Tokens             TokenSource
	Snapshots          SnapshotProvider
	Zoekt              IndexPublisher
	Enricher           Enricher
	MinFreeBytes       uint64
	MaxRepositoryBytes int64
	RenewEvery         time.Duration
	ReapEvery          time.Duration
	CleanupTimeout     time.Duration
	Metrics            *observability.Metrics
	// Logger receives one record per failed job with the phase error; job
	// rows only keep the error code. Credentials never reach these errors.
	Logger *slog.Logger
	// contains filtered or unexported fields
}

func (*Worker) Run

func (worker *Worker) Run(ctx context.Context) error

func (*Worker) RunOne

func (worker *Worker) RunOne(ctx context.Context) (worked bool, resultErr error)

type ZoektIndexer

type ZoektIndexer struct {
	Binary, IndexDir  string
	Runner            Runner
	Client            *zoekt.Client
	IndexTimeout      time.Duration
	VisibilityTimeout time.Duration
}

func (*ZoektIndexer) Index

func (indexer *ZoektIndexer) Index(ctx context.Context, repo repository.Repository, source string) (resultErr error)

func (*ZoektIndexer) WaitVisible

func (indexer *ZoektIndexer) WaitVisible(ctx context.Context, repositoryID uint32, branch, version string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL