Documentation
¶
Overview ¶
Package search provides gRPC handlers for the search service.
Package search provides code search functionality using Zoekt.
Package search provides code search functionality using Zoekt.
Index ¶
- type Config
- type IndexLocalRequest
- type IndexRequest
- type IndexResult
- type Indexer
- func (i *Indexer) Close() error
- func (i *Indexer) DeleteIndex(displayPath string) error
- func (i *Indexer) GetIndexSize(displayPath string) (int64, error)
- func (i *Indexer) IndexExists(displayPath string) bool
- func (i *Indexer) IndexLocalDir(ctx context.Context, req IndexLocalRequest) (*IndexResult, error)
- func (i *Indexer) IndexRepository(ctx context.Context, req IndexRequest) (*IndexResult, error)
- func (i *Indexer) RegisterStorageMapping(displayPath, storageID string)
- func (i *Indexer) ReloadSearcher() error
- func (i *Indexer) Search(ctx context.Context, req SearchRequest) (*SearchResults, error)
- type Job
- type MatchRange
- type RepoMeta
- type SearchRequest
- type SearchResult
- type SearchResults
- type Service
- func (s *Service) Close() error
- func (s *Service) DeleteIndex(ctx context.Context, req *pb.DeleteIndexRequest) (*pb.DeleteIndexResponse, error)
- func (s *Service) GetIndexStatus(ctx context.Context, req *pb.IndexStatusRequest) (*pb.IndexStatusResponse, error)
- func (s *Service) GetStats(ctx context.Context, req *pb.StatsRequest) (*pb.StatsResponse, error)
- func (s *Service) IndexRepository(ctx context.Context, req *pb.IndexRequest) (*pb.IndexResponse, error)
- func (s *Service) ListIndexes(ctx context.Context, req *pb.ListIndexesRequest) (*pb.ListIndexesResponse, error)
- func (s *Service) RebuildAllIndexes(ctx context.Context, req *pb.RebuildAllIndexesRequest) (*pb.RebuildAllIndexesResponse, error)
- func (s *Service) RebuildIndex(ctx context.Context, req *pb.RebuildIndexRequest) (*pb.RebuildIndexResponse, error)
- func (s *Service) Search(ctx context.Context, req *pb.SearchRequest) (*pb.SearchResponse, error)
- type ServiceStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
IndexDir string // Directory for Zoekt indexes
CacheDir string // Directory for git clones during indexing
Workers int // Number of concurrent indexing workers
QueueSize int // Size of job queue
RouterAddr string // Router address for cluster access (enables fetching from storage nodes)
Logger *slog.Logger
}
Config holds service configuration
type IndexLocalRequest ¶
IndexLocalRequest contains parameters for indexing a local directory
type IndexRequest ¶
IndexRequest contains repository indexing parameters
type IndexResult ¶
IndexResult contains indexing results
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer manages Zoekt indexing and searching
func NewIndexer ¶
func NewIndexer(indexDir, cacheDir string, monofsClient client.MonoFSClient, logger *slog.Logger) (*Indexer, error)
NewIndexer creates a new Zoekt indexer
func (*Indexer) DeleteIndex ¶
DeleteIndex removes the index for a repository by display path
func (*Indexer) GetIndexSize ¶
GetIndexSize returns the index size for a repository by display path
func (*Indexer) IndexExists ¶
IndexExists checks if an index exists for a repository by display path
func (*Indexer) IndexLocalDir ¶
func (i *Indexer) IndexLocalDir(ctx context.Context, req IndexLocalRequest) (*IndexResult, error)
IndexLocalDir indexes a local directory directly (for testing)
func (*Indexer) IndexRepository ¶
func (i *Indexer) IndexRepository(ctx context.Context, req IndexRequest) (*IndexResult, error)
IndexRepository indexes a git repository
func (*Indexer) RegisterStorageMapping ¶
RegisterStorageMapping registers a DisplayPath to StorageID mapping. This allows the Search function to return StorageID in results. Call this for all known repositories on startup.
func (*Indexer) ReloadSearcher ¶
ReloadSearcher reloads the searcher to pick up new indexes
func (*Indexer) Search ¶
func (i *Indexer) Search(ctx context.Context, req SearchRequest) (*SearchResults, error)
Search performs a code search
type Job ¶
type Job struct {
ID string `json:"id"`
StorageID string `json:"storage_id"`
DisplayPath string `json:"display_path"`
RepoURL string `json:"repo_url"`
Branch string `json:"branch"`
Status pb.IndexStatus `json:"status"`
Progress float32 `json:"progress"`
FilesCount int64 `json:"files_count"`
IndexSize int64 `json:"index_size"`
QueuedAt time.Time `json:"queued_at"`
StartedAt time.Time `json:"started_at"`
CompletedAt time.Time `json:"completed_at"`
ErrorMessage string `json:"error_message"`
}
Job represents an indexing job
type RepoMeta ¶
type RepoMeta struct {
StorageID string `json:"storage_id"`
DisplayPath string `json:"display_path"`
RepoURL string `json:"repo_url"`
Branch string `json:"branch"`
FilesCount int64 `json:"files_count"`
IndexSize int64 `json:"index_size"`
LastIndexed time.Time `json:"last_indexed"`
}
RepoMeta stores repository metadata for search
type SearchRequest ¶
type SearchRequest struct {
Query string
StorageID string // Optional: limit to specific repo
MaxResults int
CaseSensitive bool
Regex bool
FilePatterns []string
}
SearchRequest contains search parameters
type SearchResult ¶
type SearchResult struct {
StorageID string
DisplayPath string
FilePath string
LineNumber int
LineContent string
Matches []MatchRange
BeforeContext string
AfterContext string
}
SearchResult contains a single search match
type SearchResults ¶
type SearchResults struct {
Results []SearchResult
TotalMatches int64
FilesSearched int64
Duration time.Duration
Truncated bool
}
SearchResults contains all search results
type Service ¶
type Service struct {
pb.UnimplementedMonoFSSearchServer
// contains filtered or unexported fields
}
Service implements the MonoFSSearch gRPC service
func NewService ¶
NewService creates a new search service
func (*Service) DeleteIndex ¶
func (s *Service) DeleteIndex(ctx context.Context, req *pb.DeleteIndexRequest) (*pb.DeleteIndexResponse, error)
DeleteIndex implements the DeleteIndex RPC
func (*Service) GetIndexStatus ¶
func (s *Service) GetIndexStatus(ctx context.Context, req *pb.IndexStatusRequest) (*pb.IndexStatusResponse, error)
GetIndexStatus implements the GetIndexStatus RPC
func (*Service) GetStats ¶
func (s *Service) GetStats(ctx context.Context, req *pb.StatsRequest) (*pb.StatsResponse, error)
GetStats implements the GetStats RPC
func (*Service) IndexRepository ¶
func (s *Service) IndexRepository(ctx context.Context, req *pb.IndexRequest) (*pb.IndexResponse, error)
IndexRepository implements the IndexRepository RPC
func (*Service) ListIndexes ¶
func (s *Service) ListIndexes(ctx context.Context, req *pb.ListIndexesRequest) (*pb.ListIndexesResponse, error)
ListIndexes implements the ListIndexes RPC
func (*Service) RebuildAllIndexes ¶
func (s *Service) RebuildAllIndexes(ctx context.Context, req *pb.RebuildAllIndexesRequest) (*pb.RebuildAllIndexesResponse, error)
RebuildAllIndexes implements the RebuildAllIndexes RPC
func (*Service) RebuildIndex ¶
func (s *Service) RebuildIndex(ctx context.Context, req *pb.RebuildIndexRequest) (*pb.RebuildIndexResponse, error)
RebuildIndex implements the RebuildIndex RPC
func (*Service) Search ¶
func (s *Service) Search(ctx context.Context, req *pb.SearchRequest) (*pb.SearchResponse, error)
Search implements the Search RPC
type ServiceStats ¶
type ServiceStats struct {
SearchesTotal int64 `json:"searches_total"`
SearchDurationTotal int64 `json:"search_duration_total_ms"`
StartedAt time.Time `json:"started_at"`
JobsQueued int64 `json:"jobs_queued"`
JobsCompleted int64 `json:"jobs_completed"`
JobsFailed int64 `json:"jobs_failed"`
JobsRejected int64 `json:"jobs_rejected"`
}
ServiceStats tracks service statistics