Help us shape the future of Go! Take the 2026 Go Developer Survey

scheduler

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

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) GetStats

func (s *Scheduler) GetStats(ctx context.Context) (*Stats, error)

GetStats returns scheduler statistics.

func (*Scheduler) ManualSync

func (s *Scheduler) ManualSync(ctx context.Context, repoID int64) error

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

func (s *Scheduler) SetSCIPService(svc *scip.Service)

SetSCIPService sets the SCIP service for orphan SCIP database cleanup.

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context) error

Start begins the scheduler loop.

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop halts the scheduler.

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.

Jump to

Keyboard shortcuts

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