Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidStrategy reports an unknown strategy set. ErrInvalidStrategy = errors.New("invalid strategy") // ErrNoToken reports a user token not set when exporting a report // to benchttp server. ErrNoToken = errors.New("user token not set") // ErrTemplateFailTriggered a fail triggered by a user // using the function {{ fail }} in an output template. ErrTemplateFailTriggered = errors.New("test failed") )
Functions ¶
This section is empty.
Types ¶
type ExportError ¶
type ExportError struct {
Errors []error
}
ExportError is the error type returned by Report.Export.
func ExportErrorOf ¶ added in v1.0.0
func ExportErrorOf(err error) *ExportError
ExportErrorOf reads err as an ExportError and returns it. If err is not an ExportError, it returns an empty *ExportError (non nil) for convenience.
func (*ExportError) Error ¶
func (e *ExportError) Error() string
Error returns the joined errors of ExportError as a string.
func (*ExportError) HasAuthError ¶ added in v1.0.0
func (e *ExportError) HasAuthError() bool
HasAuthError returns true if any of the errors in ExportError is an error related to authentification, i.e. ErrNoToken or an export.HTTPResponseError with code http.StatusUnauthorized.
type Report ¶ added in v1.0.0
type Report struct { Benchmark requester.Benchmark Metadata struct { Config config.Global FinishedAt time.Time } // contains filtered or unexported fields }
Report represent a benchmark result as exported by the runner.
func New ¶
New returns a Report initialized with the input benchmark, the config used to run it and a user token. The user token is used to send export the Report to Benchttp server. If config.OutputBenchttp is not set in cfg, then the token is ignored.
func (*Report) Export ¶ added in v1.0.0
Export exports the Report using the Strategies set in the embedded config.Global. If any error occurs for a given Strategy, it does not block the other exports and returns an ExportError listing the errors.
func (*Report) HTTPRequest ¶ added in v1.0.0
HTTPRequest returns the *http.Request to be sent to Benchttp server. The Report is encoded as gob in the request body.