benchttp

package
v0.0.0-...-b1b3351 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codestats

type Codestats struct {
	Code1xx int `json:"code1xx"`
	Code2xx int `json:"code2xx"`
	Code3xx int `json:"code3xx"`
	Code4xx int `json:"code4xx"`
	Code5xx int `json:"code5xx"`
}

Codestats represents the code stats related to a computed stats group

type Report

type Report struct {
	// Benchmark represents the detailed collection of requests done
	// during a Benchttp benchmark run.
	Benchmark struct {
		// Record represents the summary of a HTTP response.
		Records []struct {
			Time  time.Duration `firestore:"time" json:"time"`
			Code  int           `firestore:"code" json:"code"`
			Bytes int           `firestore:"bytes" json:"bytes"`
			Error string        `firestore:"error,omitempty" json:"error,omitempty"`

			// Event is a stage of an outgoing HTTP request associated with a timestamp.
			Events []struct {
				Name string        `firestore:"name" json:"name"`
				Time time.Duration `firestore:"time" json:"time"`
			} `firestore:"events" json:"events"`
		} `firestore:"records" json:"records"`

		Length   int           `firestore:"length" json:"length"`
		Success  int           `firestore:"success" json:"success"`
		Fail     int           `firestore:"fail" json:"fail"`
		Duration time.Duration `firestore:"duration" json:"duration"`
	} `firestore:"benchmark" json:"benchmark"`

	Metadata struct {
		// Config represents the global configuration of the runner.
		Config struct {
			// Request contains the confing options relative to a single request.
			Request struct {
				Method string      `firestore:"method" json:"method"`
				URL    *url.URL    `firestore:"url" json:"url"`
				Header http.Header `firestore:"header" json:"header"`

				Body struct {
					Type    string `firestore:"type" json:"type"`
					Content []byte `firestore:"content" json:"content"`
				} `firestore:"body" json:"body"`
			} `firestore:"request" json:"request"`

			// Runner contains options relative to the runner.
			Runner struct {
				Requests       int           `firestore:"requests" json:"requests"`
				Concurrency    int           `firestore:"concurrency" json:"concurrency"`
				Interval       time.Duration `firestore:"interval" json:"interval"`
				RequestTimeout time.Duration `firestore:"requestTimeout" json:"requestTimeout"`
				GlobalTimeout  time.Duration `firestore:"globalTimeout" json:"globalTimeout"`
			} `firestore:"runner" json:"runner"`

			// Output contains options relative to the output.
			Output struct {
				Out      []string
				Silent   bool
				Template string
			} `firestore:"-" json:"-"`
		} `firestore:"config" json:"config"`

		FinishedAt time.Time `firestore:"finishedAt" json:"finishedAt"`
	} `firestore:"metadata" json:"metadata"`
}

Report represents the result of a Benchttp benchmark run.

type ReportService

type ReportService interface {
	// Create creates and stores a Report in the data layer
	// and returns its ID.
	Create(ctx context.Context, data Report) (string, error)

	// Retrieve retrieves a Report by ID from the data layer.
	Retrieve(ctx context.Context, id string) (Report, error)
}

ReportService defines the interface to implement by a service facade inside the application.

type Stats

type Stats struct {
	Descriptor StatsDescriptor `json:"descriptor"`
	Code       Codestats       `json:"code"`
	Time       Timestats       `json:"time"`
}

Stats contains StatsDescriptor, Codestats and Timestats of a given computed stats group

type StatsDescriptor

type StatsDescriptor struct {
	ID         string    `json:"id"`
	FinishedAt time.Time `json:"finishedAt"`
}

StatsDescriptor contains a computed stats group description information

type StatsService

type StatsService interface {
	// ListAvailable retrieves all the StatsDescriptor (Tag and
	// FinishedAt) concerning the reports of a given user.
	ListAvailable(id string) ([]StatsDescriptor, error)
	// GetByID retrieves computed stats,
	// when provided with a StatsDescriptor id.
	GetByID(id string) (Stats, error)
}

StatsService defines the interface to implement by a service facade inside the application.

type Timestats

type Timestats struct {
	Min     float64   `json:"min"`
	Max     float64   `json:"max"`
	Mean    float64   `json:"mean"`
	Median  float64   `json:"median"`
	StdDev  float64   `json:"standardDeviation"`
	Deciles []float64 `json:"deciles"`
}

Timestats represents the time stats related to a computed stats group

Jump to

Keyboard shortcuts

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