output

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func New(bk requester.Benchmark, cfg config.Global, token string) *Report

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

func (rep *Report) Export() error

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

func (rep *Report) HTTPRequest() (*http.Request, error)

HTTPRequest returns the *http.Request to be sent to Benchttp server. The Report is encoded as gob in the request body.

func (*Report) String added in v1.0.0

func (rep *Report) String() string

String returns a default summary of the Report as a string.

type Strategy

type Strategy uint8

Strategy reprents an output strategy for the input value.

const (
	// StrategyStdout writes the input value to os.Stdout.
	Stdout Strategy = 1 << iota
	// JSONFile writes the input value as a file
	// in the working directory.
	JSONFile
	// Benchttp sends the input value to Benchttp API server.
	Benchttp
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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