watch

package
v3.33.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxConsecutiveErrors is the number of consecutive polling failures
	// before the watch loop aborts.
	DefaultMaxConsecutiveErrors = 10

	// DefaultRequestTimeout is the per-request timeout for each polling call.
	DefaultRequestTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func IsTerminalBuildState

func IsTerminalBuildState(state string) bool

IsTerminalBuildState returns true if the build state is a terminal state.

func WatchBuild

func WatchBuild(
	ctx context.Context,
	client *buildkite.Client,
	org, pipeline string,
	buildNumber int,
	interval time.Duration,
	onStatus StatusFunc,
) (buildkite.Build, error)

WatchBuild polls a build until it reaches a terminal state (FinishedAt != nil). It calls onStatus after each successful poll so callers can render progress.

Types

type BuildStatus

type BuildStatus struct {
	NewlyFailed  []buildkite.Job
	Running      []buildkite.Job
	TotalRunning int
	Summary      JobSummary
	Build        buildkite.Build
}

BuildStatus is the output of JobTracker.Update().

type FormattedJob

type FormattedJob struct {
	buildkite.Job
}

FormattedJob wraps a Buildkite job with watch-specific formatting and classification helpers.

func NewFormattedJob

func NewFormattedJob(j buildkite.Job) FormattedJob

NewFormattedJob wraps a Buildkite job.

func (FormattedJob) DisplayName

func (j FormattedJob) DisplayName() string

DisplayName returns a human-readable name for a job.

func (FormattedJob) Duration

func (j FormattedJob) Duration() time.Duration

Duration returns the elapsed duration for a job.

func (FormattedJob) IsFailed

func (j FormattedJob) IsFailed() bool

func (FormattedJob) IsSoftFailed

func (j FormattedJob) IsSoftFailed() bool

func (FormattedJob) IsTerminalFailureState

func (j FormattedJob) IsTerminalFailureState() bool

type JobSummary

type JobSummary struct {
	Passed     int
	Failed     int
	SoftFailed int
	Running    int
	Scheduled  int
	Blocked    int
	Skipped    int
	Waiting    int
}

JobSummary aggregates job counts by high-level state.

func (JobSummary) String

func (s JobSummary) String() string

String returns a human-readable summary of non-zero job counts.

type JobTracker

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

JobTracker tracks job state changes across polls.

func NewJobTracker

func NewJobTracker() *JobTracker

NewJobTracker creates a new JobTracker.

func (*JobTracker) AllFailed

func (t *JobTracker) AllFailed() []buildkite.Job

AllFailed returns all failed jobs.

func (*JobTracker) Update

func (t *JobTracker) Update(b buildkite.Build) BuildStatus

Update processes a build and returns the current status with any state changes.

type StatusFunc

type StatusFunc func(b buildkite.Build) error

StatusFunc is called on each successful poll with the latest build state. Returning an error aborts the watch loop and propagates that error to the caller.

Jump to

Keyboard shortcuts

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