operation

package
v1.78.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package operation runs one operation of Current, Global or the package Reconciler (the preparation of a candidate): its steps, in order, in a worker goroutine that the owner's loop starts and cancels. It decides nothing and reports nothing; the steps are closures over a per-operation state the owner keeps, so this package knows nothing of its owners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition int

Condition is the condition a failing step reports on; unused by Prepare and Notify, whose failures go to the Candidate section.

const (
	HooksProcessed Condition = iota
	ManifestsApplied
)

type Kind

type Kind string

Kind names an operation.

const (
	Run       Kind = "run"
	Disable   Kind = "disable"
	Uninstall Kind = "uninstall"
	Sync      Kind = "sync"
	Prepare   Kind = "prepare" // Prepare attaches and loads a candidate (the package Reconciler's).
	Notify    Kind = "notify"  // Notify sends the update notification (the package Reconciler's).
)

type Operation

type Operation struct {
	Kind Kind
	// Key identifies what the operation started with (the Inputs of a run or a disable), so the
	// owner can tell whether a newer decision supersedes it.
	Key string
	// contains filtered or unexported fields
}

Operation is one operation in progress.

func Start

func Start(ctx context.Context, name string, kind Kind, key string, steps []Step) *Operation

Start runs steps in order in a new goroutine under a child of ctx and stops at the first failure; name is the package the spans carry. Non-blocking.

func (*Operation) Cancel

func (o *Operation) Cancel()

Cancel cancels the operation's context; the result still arrives on Done. Idempotent.

func (*Operation) Done

func (o *Operation) Done() <-chan Result

Done delivers the result once, when the last step returned. Nil-safe: a nil Operation's channel is nil and blocks, so an idle owner selects on it unchanged.

type Result

type Result struct {
	Kind Kind
	Key  string
	// Failed is the step that failed; nil on success.
	Failed *Step
	Err    error
	// Canceled: the operation's context was cancelled when the step failed. The owner cancelled
	// it, so it is not a failure.
	Canceled bool
}

Result is what an operation ended with.

type Step

type Step struct {
	Name      string
	Condition Condition
	Reason    string
	Run       func(ctx context.Context) error
}

Step is one named unit of an operation; Condition and Reason say what its failure reports. Run executes in the worker goroutine.

Jump to

Keyboard shortcuts

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