results

package
v0.0.0-...-35fe99a Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateSucceeded string = "succeeded"
	StateFailed    string = "failed"
)

Variables

This section is empty.

Functions

func DefaultReason

func DefaultReason(err error) error

DefaultReason is a constructor that adds a reason if needed, when we want to ensure that consumers downstream of a callsite have an Error.

annotated := DefaultReason(doSomething())

func Reasons

func Reasons(errs ...error) (ret []string)

Reasons provides the chains of error reasons. Each item in the return value is a single chain divided by colons. Aggregate errors — those whose type provides an `Errors` method returning a list of errors — are recursively expanded, generating a separate chain for each child.

Types

type BuilderWithReason

type BuilderWithReason struct {
	Error
}

BuilderWithReason starts the builder chain

func ForReason

func ForReason(reason Reason) *BuilderWithReason

ForReason is a constructor for an Error from a Reason. We expect users to then add a child and a error message to this Error.

func (*BuilderWithReason) ForError

func (e *BuilderWithReason) ForError(err error) error

ForError is a constructor for when a caller does not want to add a child but instead wants a simple error. For instance, wrapping the outcome of a function that doesn't return an Error itself:

err := results.ForReason(results.ReasonLoadingArgs).ForError(doSomething())

func (*BuilderWithReason) WithError

WithError is a builder that adds a child to the Error. We expect users to continue to build the Error by adding a message.

type BuilderWithReasonAndError

type BuilderWithReasonAndError struct {
	Error
}

BuilderWithReasonAndError adds a child error to the builder

func (*BuilderWithReasonAndError) Errorf

func (e *BuilderWithReasonAndError) Errorf(format string, args ...interface{}) error

Errorf is a builder that adds in the main error to an Error. This is expected to be the final builder/producer in a chain, so we return an error and not an Error

type Error

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

Error holds a message and a child, allowing for an error The common use-case here will be to wrap errors from callsites:

if err := doSomething(data); err != nil {
    return results.ForReason(results.ReasonFoo).WithError(err).Errorf("could not do something for data: %v", data)
}

func (*Error) Error

func (e *Error) Error() string

Error makes an Error an error

func (*Error) Is

func (e *Error) Is(target error) bool

Is allows us to say we are an Error

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap allows nesting of errors

type Options

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

Options holds the configuration options for connecting to the remote aggregation server

func (*Options) Bind

func (o *Options) Bind(flag *flag.FlagSet)

Bind adds flags for the options

func (*Options) PodScalerReporter

func (o *Options) PodScalerReporter() (PodScalerReporter, error)

func (*Options) Reporter

func (o *Options) Reporter(spec *api.JobSpec, consoleHost string) (Reporter, error)

Client returns an HTTP or HTTPs client, based on the options

func (*Options) Validate

func (o *Options) Validate() error

Validate checks if the Options elements are empty

type PodScalerReporter

type PodScalerReporter interface {
	ReportResourceConfigurationWarning(workloadName, workloadType, configuredAmount, determinedAmount, resourceType string)
}

type PodScalerRequest

type PodScalerRequest struct {
	WorkloadName     string
	WorkloadType     string
	ConfiguredAmount string
	DeterminedAmount string
	ResourceType     string
}

PodScalerRequest holds the data from pod-scaler used to report a result to an aggregation server

type Reason

type Reason string
const (
	// ReasonUnknown is default reason. Occurrences of this reason in metrics
	// indicate a bug, a failure to identify the reason for an error somewhere.
	ReasonUnknown Reason = "unknown"
)

type Reporter

type Reporter interface {
	// Report sends a report for this error to an aggregation server.
	// This action is best-effort and errors are logged but not exposed.
	// Err may be nil in which case a success is reported.
	Report(err error)
}

type Request

type Request struct {
	// JobName is the name of the job for which a result is being reported
	JobName string `json:"job_name"`
	// Type is the type of job ("presubmit", "postsubmit", "periodic" or "batch")
	Type string `json:"type"`
	// Cluster is the cluster's console hostname
	Cluster string `json:"cluster"`
	// State is "succeeded" or "failed"
	State string `json:"state"`
	// Reason is a colon-delimited list of reasons for failure
	Reason string `json:"reason"`
}

Request holds the data used to report a result to an aggregation server

Jump to

Keyboard shortcuts

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