scheduler

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitHubClient

type GitHubClient interface {
	DispatchWorkflow(ctx context.Context, owner, repo, workflowFile, ref string) error
	GetVariable(ctx context.Context, owner, repo, name string) (string, error)
	SetVariable(ctx context.Context, owner, repo, name, value string) error
	GetInstallationRepos(ctx context.Context) ([]github.Repository, error)
	GetWorkflowFiles(ctx context.Context, owner, repo string) ([]github.WorkflowFile, error)
	GetFileContent(ctx context.Context, owner, repo, path, ref string) (string, error)
}

GitHubClient is the GitHub API interface used by the scheduler.

type JobDetail

type JobDetail struct {
	Owner        string    `json:"owner"`
	Repo         string    `json:"repo"`
	WorkflowFile string    `json:"workflow_file"`
	CronExpr     string    `json:"cron_expr"`
	NextRun      time.Time `json:"next_run"`
}

JobDetail holds detailed information about a registered job.

type Reconciler

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

Reconciler applies diffs between desired state and actual state.

func NewReconciler

func NewReconciler(client GitHubClient, sched *Scheduler, cfg *config.ReconcileConfig) *Reconciler

NewReconciler creates a new Reconciler.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context) error

Reconcile applies diffs between desired state (annotations) and actual state (registered cron jobs).

type Scheduler

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

Scheduler manages cron jobs.

func New

func New(client GitHubClient, cfg *config.ReconcileConfig, loc *time.Location) *Scheduler

New creates a new Scheduler.

func (*Scheduler) AddJob

func (s *Scheduler) AddJob(annotation github.CronAnnotation) error

AddJob registers a cron job.

func (*Scheduler) GetJobDetails

func (s *Scheduler) GetJobDetails() []JobDetail

GetJobDetails returns details of all registered jobs (StatusProvider).

func (*Scheduler) GetLastReconcileTime

func (s *Scheduler) GetLastReconcileTime() time.Time

GetLastReconcileTime returns the last reconcile timestamp (StatusProvider).

func (*Scheduler) GetRegisteredJobCount

func (s *Scheduler) GetRegisteredJobCount() int

GetRegisteredJobCount returns the number of registered jobs (StatusProvider).

func (*Scheduler) GetRegisteredKeys

func (s *Scheduler) GetRegisteredKeys() []github.CronJobKey

GetRegisteredKeys returns all registered job keys.

func (*Scheduler) GetSkippedAnnotations added in v0.2.0

func (s *Scheduler) GetSkippedAnnotations() []scanner.SkippedAnnotation

GetSkippedAnnotations returns annotations that failed validation (StatusProvider).

func (*Scheduler) RemoveJob

func (s *Scheduler) RemoveJob(key github.CronJobKey)

RemoveJob removes a cron job.

func (*Scheduler) RunReconcileLoop

func (s *Scheduler) RunReconcileLoop(ctx context.Context, interval time.Duration)

RunReconcileLoop runs the reconciliation loop.

func (*Scheduler) SetSkippedAnnotations added in v0.2.0

func (s *Scheduler) SetSkippedAnnotations(skipped []scanner.SkippedAnnotation)

SetSkippedAnnotations updates the skipped annotations from the last scan.

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop stops the scheduler.

type StateClient

type StateClient interface {
	GetVariable(ctx context.Context, owner, repo, name string) (string, error)
	SetVariable(ctx context.Context, owner, repo, name, value string) error
}

StateClient is the interface used by StateManager.

type StateManager

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

StateManager manages state via GitHub Actions Variables.

func NewStateManager

func NewStateManager(client StateClient) *StateManager

NewStateManager creates a new StateManager.

func (*StateManager) GetLastDispatchTime

func (sm *StateManager) GetLastDispatchTime(ctx context.Context, annotation github.CronAnnotation) (time.Time, error)

GetLastDispatchTime retrieves the last dispatch time.

func (*StateManager) SetLastDispatchTime

func (sm *StateManager) SetLastDispatchTime(ctx context.Context, annotation github.CronAnnotation, t time.Time) error

SetLastDispatchTime persists the dispatch time.

Jump to

Keyboard shortcuts

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