indexer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package indexer provides the indexer HTTP server for federated file access.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetShardForRepo

func GetShardForRepo(repoName string, totalShards int) int

GetShardForRepo returns the shard index for a repository name.

Types

type ReplaceExecuteRequest

type ReplaceExecuteRequest struct {
	SearchPattern string               `json:"search_pattern"`
	ReplaceWith   string               `json:"replace_with"`
	IsRegex       bool                 `json:"is_regex"`
	CaseSensitive bool                 `json:"case_sensitive"`
	Matches       []queue.ReplaceMatch `json:"matches"`
	BranchName    string               `json:"branch_name,omitempty"`
	MRTitle       string               `json:"mr_title,omitempty"`
	MRDescription string               `json:"mr_description,omitempty"`
	UserTokens    map[string]string    `json:"user_tokens,omitempty"`
	ReposReadOnly bool                 `json:"repos_readonly"`
}

ReplaceExecuteRequest is the request body for federated replace execution.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server provides HTTP endpoints for federated file access in sharded deployments. Each indexer runs this server to expose its local repos for browsing and replace operations.

func NewServer

func NewServer(
	cfg ServerConfig,
	logger *zap.Logger,
	filesService *files.Service,
	replaceService *replace.Service,
	scipService *scip.Service,
	q *queue.Queue,
) *Server

NewServer creates a new indexer HTTP server.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server.

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server.

type ServerConfig

type ServerConfig struct {
	Addr        string
	ReposPath   string
	ShardIndex  int
	TotalShards int
}

ServerConfig holds configuration for the indexer HTTP server.

type ShardConfig

type ShardConfig = sharding.Config

ShardConfig holds sharding configuration. Delegates to the shared sharding package.

func GetShardConfig

func GetShardConfig() ShardConfig

GetShardConfig reads sharding configuration from environment.

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

Worker processes index jobs from the queue.

func NewWorker

func NewWorker(
	cfg *config.Config,
	logger *zap.Logger,
	q *queue.Queue,
	pool db.Pool,
	tokenEncryptor *crypto.TokenEncryptor,
) *Worker

NewWorker creates a new indexer worker.

func (*Worker) CloneRepository

func (w *Worker) CloneRepository(
	ctx context.Context,
	url string,
	name string,
	conn *repos.Connection,
) (string, error)

CloneRepository clones a repository to the local filesystem.

func (*Worker) FetchRepository

func (w *Worker) FetchRepository(
	ctx context.Context,
	repoPath string,
	conn *repos.Connection,
) error

FetchRepository fetches updates for a repository.

func (*Worker) IndexRepository

func (w *Worker) IndexRepository(ctx context.Context, repoPath string, branches []string) error

IndexRepository indexes a single repository.

func (*Worker) Run

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

Run starts the worker loop. It supports graceful shutdown: when ctx is canceled, it will finish processing the current job before returning (up to shutdownTimeout).

func (*Worker) SetSCIPService

func (w *Worker) SetSCIPService(svc *scipkg.Service)

SetSCIPService sets the optional SCIP service for code intelligence indexing.

Jump to

Keyboard shortcuts

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