Documentation
¶
Index ¶
Constants ¶
const ( // MaxFileSize is the maximum file size to process (10MB). MaxFileSize = 10 * 1024 * 1024 // CloneTimeout is the timeout for git clone operations. CloneTimeout = 10 * time.Minute // PushTimeout is the timeout for git push operations. PushTimeout = 5 * time.Minute // DefaultConcurrency is the default number of concurrent repository operations. DefaultConcurrency = 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecuteOptions ¶
type ExecuteOptions 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"`
}
ExecuteOptions configures a replace execution (used by federated client).
type ExecuteRequest ¶
type ExecuteRequest 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"`
}
ExecuteRequest is the request body for federated replace execution.
type ExecuteResult ¶
type ExecuteResult struct {
TotalFiles int `json:"total_files"`
ModifiedFiles int `json:"modified_files"`
RepoResults []RepoResult `json:"repo_results"`
}
ExecuteResult represents the result of a replace execution.
type FederatedClient ¶
type FederatedClient struct {
// contains filtered or unexported fields
}
FederatedClient handles proxying replace requests to the correct indexer shards.
func NewFederatedClient ¶
func NewFederatedClient(indexerService string, indexerPort, totalShards int) *FederatedClient
NewFederatedClient creates a client for federated replace operations.
func (*FederatedClient) Execute ¶
func (c *FederatedClient) Execute( ctx context.Context, opts ExecuteOptions, ) (*ExecuteResult, error)
Execute fans out replace operations to the correct indexer shards.
func (*FederatedClient) GetShardForRepo ¶
func (c *FederatedClient) GetShardForRepo(repoName string) int
GetShardForRepo returns which shard owns a repo.
type PrecomputedMatch ¶
PrecomputedMatch represents a file match from a previous preview.
type ReplaceOptions ¶
type ReplaceOptions struct {
SearchPattern string
ReplaceWith string
IsRegex bool
CaseSensitive bool
FilePatterns []string // e.g., "*.go", "*.ts"
Languages []string // e.g., "go", "typescript"
ContextLines int // Lines of context around matches (default: 2)
MRTitle string
MRDescription string
BranchName string
DryRun bool
Limit int // Max results for preview, 0 means unlimited
// PrecomputedMatches contains matches from preview (required for Execute).
// Call Preview first to get matches, then pass them to Execute.
PrecomputedMatches []PrecomputedMatch
// Concurrency limits the number of repositories processed in parallel.
// Defaults to DefaultConcurrency if not set.
Concurrency int
// UserTokens maps connection_id to user-provided token for repos without server-side auth.
// Keys are connection IDs as strings (e.g., "123").
UserTokens map[string]string
// ReposReadOnly indicates the system is in read-only mode.
// When true, only user-provided tokens can be used (never DB tokens).
// DB tokens are reserved for indexing operations only.
ReposReadOnly bool
}
ReplaceOptions configures a replace operation.
type ReplacementResult ¶
type ReplacementResult struct {
RepositoryID int64
RepositoryName string
FilesModified int
MatchCount int
MergeRequest *codehost.MergeRequest
Error string
}
ReplacementResult represents the result of a replacement operation.
type RepoResult ¶
type RepoResult struct {
RepositoryID int64 `json:"repository_id"`
RepositoryName string `json:"repository_name"`
FilesModified int `json:"files_modified"`
MRUrl string `json:"mr_url,omitempty"`
Error string `json:"error,omitempty"`
}
RepoResult represents the result for a single repository.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles search and replace operations.
func NewService ¶
func NewService( searchService *search.Service, repoService *repos.Service, workDir string, logger *zap.Logger, cfg *ServiceConfig, ) *Service
NewService creates a new replace service.
func (*Service) Execute ¶
func (s *Service) Execute(ctx context.Context, opts ReplaceOptions) ([]ReplacementResult, error)
Execute performs the replace operation using precomputed matches from preview. Matches must be provided - call Preview first to get the matches.
func (*Service) ExecuteFromOptions ¶
func (s *Service) ExecuteFromOptions( ctx context.Context, opts ExecuteOptions, ) (*ExecuteResult, error)
ExecuteFromOptions performs the replace operation using ExecuteOptions (federated API format). Converts ExecuteOptions to ReplaceOptions and calls Execute.
func (*Service) Preview ¶
func (s *Service) Preview(ctx context.Context, opts ReplaceOptions) (*search.SearchResults, error)
Preview shows what would be replaced without making changes.
type ServiceConfig ¶
type ServiceConfig struct {
Concurrency int
CloneTimeout time.Duration
PushTimeout time.Duration
MaxFileSize int64
}
ServiceConfig holds configuration for the replace service.
type ShardResult ¶
type ShardResult struct {
Shard int
Result *ExecuteResult
Error error
}
ShardResult holds the result from one shard.