Documentation
¶
Index ¶
Constants ¶
const ( StateSucceeded string = "succeeded" StateFailed string = "failed" )
Variables ¶
This section is empty.
Functions ¶
func DefaultReason ¶
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())
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 ¶
func (e *BuilderWithReason) WithError(err error) *BuilderWithReasonAndError
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) }
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options holds the configuration options for connecting to the remote aggregation server
func (*Options) PodScalerReporter ¶
func (o *Options) PodScalerReporter() (PodScalerReporter, error)
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