watcher

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package watcher provides workflow run monitoring and status tracking functionality.

Index

Constants

View Source
const PollInterval = 5 * time.Second

PollInterval is the default interval between API polls.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitHubClient

type GitHubClient interface {
	GetWorkflowRun(runID int64) (*github.WorkflowRun, error)
	GetWorkflowRunJobs(runID int64) ([]github.Job, error)
}

GitHubClient defines the interface for GitHub API operations needed by the watcher.

type JobStatus

type JobStatus struct {
	Name       string
	Status     string
	Conclusion string
	Steps      []StepStatus
}

JobStatus represents the status of a job in a watched run.

type RunUpdate

type RunUpdate struct {
	Error error
	Run   WatchedRun
	RunID int64
}

RunUpdate represents an update to a watched run.

type RunWatcher

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

RunWatcher monitors workflow runs and sends updates.

func NewWatcher

func NewWatcher(client GitHubClient) *RunWatcher

NewWatcher creates a new RunWatcher.

func (*RunWatcher) ActiveCount

func (w *RunWatcher) ActiveCount() int

ActiveCount returns the number of active runs.

func (*RunWatcher) ClearCompleted

func (w *RunWatcher) ClearCompleted()

ClearCompleted removes all completed runs from the watch list.

func (*RunWatcher) GetRun

func (w *RunWatcher) GetRun(runID int64) (*WatchedRun, bool)

GetRun returns a specific watched run.

func (*RunWatcher) GetRuns

func (w *RunWatcher) GetRuns() []WatchedRun

GetRuns returns all currently watched runs.

func (*RunWatcher) Stop

func (w *RunWatcher) Stop()

Stop stops the watcher and cleans up resources. Safe to call multiple times.

func (*RunWatcher) TotalCount

func (w *RunWatcher) TotalCount() int

TotalCount returns the total number of watched runs.

func (*RunWatcher) Unwatch

func (w *RunWatcher) Unwatch(runID int64)

Unwatch stops watching a workflow run.

func (*RunWatcher) Updates

func (w *RunWatcher) Updates() <-chan RunUpdate

Updates returns the channel for receiving run updates.

func (*RunWatcher) Watch

func (w *RunWatcher) Watch(runID int64, workflowName string)

Watch starts watching a workflow run.

type StepStatus

type StepStatus struct {
	Name       string
	Status     string
	Conclusion string
	Number     int
}

StepStatus represents the status of a step in a job.

type WatchedRun

type WatchedRun struct {
	UpdatedAt  time.Time
	LastError  error
	Workflow   string
	Status     string
	Conclusion string
	HTMLURL    string
	Jobs       []JobStatus
	RunID      int64
}

WatchedRun represents a run being watched.

func (WatchedRun) IsActive

func (r WatchedRun) IsActive() bool

IsActive returns true if the run is still in progress.

func (WatchedRun) IsSuccess

func (r WatchedRun) IsSuccess() bool

IsSuccess returns true if the run completed successfully.

Jump to

Keyboard shortcuts

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