Documentation
¶
Index ¶
- type Config
- type RepoNeedingSync
- type Scheduler
- func (s *Scheduler) GetStats(ctx context.Context) (*Stats, error)
- func (s *Scheduler) ManualSync(ctx context.Context, repoID int64) error
- func (s *Scheduler) SetPollInterval(ctx context.Context, repoID int64, interval time.Duration) error
- func (s *Scheduler) SetSCIPService(svc *scip.Service)
- func (s *Scheduler) Start(ctx context.Context) error
- func (s *Scheduler) Stop()
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Enabled controls whether the scheduler runs
Enabled bool
// DefaultPollInterval is the default interval between sync checks
DefaultPollInterval time.Duration
// CheckInterval is how often the scheduler checks for repos needing sync
CheckInterval time.Duration
// StaleThreshold is how long a repo must be in 'indexing' or 'cloning' status
// before it's considered stuck and reset to 'pending'. Default: 1 hour.
StaleThreshold time.Duration
// PendingJobTimeout is how long a repo can be in 'pending' status without
// an active job before it's considered stuck and re-queued. Default: 5 minutes.
// This should be short to quickly recover from job queue issues.
PendingJobTimeout time.Duration
// MaxConcurrentChecks limits parallel git fetch checks
MaxConcurrentChecks int
// ReposPath is the path where repositories are cloned
ReposPath string
// IndexPath is the path where Zoekt index shards are stored
IndexPath string
// JobRetentionPeriod is how long to keep completed/failed jobs
JobRetentionPeriod time.Duration
// OrphanCleanupInterval is how often to check for orphan shards (0 to disable)
OrphanCleanupInterval time.Duration
}
Config holds scheduler configuration.
type RepoNeedingSync ¶
type RepoNeedingSync struct {
ID int64
ConnectionID int64
Name string
CloneURL string
DefaultBranch string
Branches []string // Additional branches to index
IndexStatus string
LastIndexed *time.Time
PollInterval *time.Duration // nil means use default
LocalPath string
}
RepoNeedingSync contains info about a repo that may need syncing.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler handles automatic repository sync polling.
func New ¶
func New( cfg Config, pool db.Pool, q *queue.Queue, redisClient *redis.Client, tokenEncryptor *crypto.TokenEncryptor, logger *zap.Logger, ) *Scheduler
New creates a new scheduler.
func (*Scheduler) ManualSync ¶
ManualSync triggers an immediate sync check for a specific repo.
func (*Scheduler) SetPollInterval ¶
func (s *Scheduler) SetPollInterval( ctx context.Context, repoID int64, interval time.Duration, ) error
SetPollInterval sets a custom poll interval for a repository.
func (*Scheduler) SetSCIPService ¶
SetSCIPService sets the SCIP service for orphan SCIP database cleanup.
type Stats ¶
type Stats struct {
TotalCount int `json:"total_count"`
IndexedCount int `json:"indexed_count"`
PendingCount int `json:"pending_count"`
IndexingCount int `json:"indexing_count"`
FailedCount int `json:"failed_count"`
StaleCount int `json:"stale_count"`
NextCheckAt time.Time `json:"next_check_at"`
}
Stats holds scheduler statistics.
Click to show internal directories.
Click to hide internal directories.