v1

package
v0.55.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 17 Imported by: 7

Documentation

Overview

Package v1 implements the v1 of the k6's REST API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(cs *ControlSurface) http.Handler

NewHandler returns the top handler for the v1 REST APIs

Types

type Check added in v0.5.0

type Check struct {
	ID     string `json:"id" yaml:"id"`
	Path   string `json:"path" yaml:"path"`
	Name   string `json:"name" yaml:"name"`
	Passes int64  `json:"passes" yaml:"passes"`
	Fails  int64  `json:"fails" yaml:"fails"`
}

Check represents a k6's check in a k6 REST API

func NewCheck added in v0.5.0

func NewCheck(c *lib.Check) Check

NewCheck constructs a new v1.Check struct that is used for a check representation in a k6 REST API

type ControlSurface added in v0.43.0

type ControlSurface struct {
	RunCtx        context.Context
	Samples       chan metrics.SampleContainer
	MetricsEngine *engine.MetricsEngine
	Scheduler     *execution.Scheduler
	RunState      *lib.TestRunState
}

ControlSurface includes the methods the REST API can use to control and communicate with the rest of k6.

type Error added in v0.5.0

type Error struct {
	Status string `json:"status,omitempty"`
	Title  string `json:"title,omitempty"`
	Detail string `json:"detail,omitempty"`
}

Error is an api error

func (Error) Error added in v0.5.0

func (e Error) Error() string

type ErrorResponse added in v0.5.0

type ErrorResponse struct {
	Errors []Error `json:"errors"`
}

ErrorResponse is a struct wrapper around multiple errors

type Group added in v0.5.0

type Group struct {
	ID     string  `json:"-" yaml:"id"`
	Path   string  `json:"path" yaml:"path"`
	Name   string  `json:"name" yaml:"name"`
	Checks []Check `json:"checks" yaml:"checks"`

	Parent   *Group   `json:"-" yaml:"-"`
	ParentID string   `json:"-" yaml:"parent-id"`
	Groups   []*Group `json:"-" yaml:"-"`
	GroupIDs []string `json:"-" yaml:"group-ids"`
}

Group represents a k6's group in a k6 REST API

func FlattenGroup added in v0.5.0

func FlattenGroup(g *Group) []*Group

FlattenGroup flattens a group and all its subgroups into a slice of groups

func NewGroup added in v0.5.0

func NewGroup(g *lib.Group, parent *Group) *Group

NewGroup constructs a new v1.Group struct that is used for a group representation in a k6 REST API

func (*Group) SetToManyReferenceIDs added in v0.5.0

func (g *Group) SetToManyReferenceIDs(name string, ids []string) error

SetToManyReferenceIDs sets to-many relations (groups) for a group

func (*Group) SetToOneReferenceID added in v0.5.0

func (g *Group) SetToOneReferenceID(name, id string) error

SetToOneReferenceID sets to-one relation (parent) for a group

type Metric added in v0.5.0

type Metric struct {
	Name string `json:"-" yaml:"name"`

	Type     NullMetricType `json:"type" yaml:"type"`
	Contains NullValueType  `json:"contains" yaml:"contains"`
	Tainted  null.Bool      `json:"tainted" yaml:"tainted"`

	Sample map[string]float64 `json:"sample" yaml:"sample"`
}

Metric represents a metric that is being collected by k6.

func NewMetric added in v0.5.0

func NewMetric(m *metrics.Metric, t time.Duration) Metric

NewMetric constructs a new v1.Metric struct that is used for a metric representation in a k6 REST API

type MetricsJSONAPI added in v0.36.0

type MetricsJSONAPI struct {
	Data []metricData `json:"data"`
}

MetricsJSONAPI is JSON API envelop for metrics

func (MetricsJSONAPI) Metrics added in v0.36.0

func (m MetricsJSONAPI) Metrics() []Metric

Metrics extract the []v1.Metric from the JSON API envelop

type NullMetricType added in v0.5.0

type NullMetricType struct {
	Type  metrics.MetricType
	Valid bool
}

NullMetricType a nullable metric struct

func (NullMetricType) MarshalJSON added in v0.5.0

func (t NullMetricType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*NullMetricType) UnmarshalJSON added in v0.5.0

func (t *NullMetricType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type NullSetupData added in v0.23.0

type NullSetupData struct {
	SetupData
	Data interface{} `json:"data,omitempty" yaml:"data"`
}

NullSetupData is wrapper around null to satisfy jsonapi

type NullValueType added in v0.5.0

type NullValueType struct {
	Type  metrics.ValueType
	Valid bool
}

NullValueType a nullable metric value struct

func (NullValueType) MarshalJSON added in v0.5.0

func (t NullValueType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*NullValueType) UnmarshalJSON added in v0.5.0

func (t *NullValueType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type SetupData added in v0.21.0

type SetupData struct {
	Data interface{} `json:"data" yaml:"data"`
}

SetupData is just a simple wrapper to satisfy jsonapi

type Status added in v0.5.0

type Status struct {
	Status lib.ExecutionStatus `json:"status" yaml:"status"`

	Paused  null.Bool `json:"paused" yaml:"paused"`
	VUs     null.Int  `json:"vus" yaml:"vus"`
	VUsMax  null.Int  `json:"vus-max" yaml:"vus-max"`
	Stopped bool      `json:"stopped" yaml:"stopped"`
	Running bool      `json:"running" yaml:"running"`
	Tainted bool      `json:"tainted" yaml:"tainted"`
}

Status represents the current status of the test run.

type StatusJSONAPI added in v0.36.0

type StatusJSONAPI struct {
	Data statusData `json:"data"`
}

StatusJSONAPI is JSON API envelop for metrics

func NewStatusJSONAPI added in v0.36.0

func NewStatusJSONAPI(s Status) StatusJSONAPI

NewStatusJSONAPI creates the JSON API status envelop

func (StatusJSONAPI) Status added in v0.36.0

func (s StatusJSONAPI) Status() Status

Status extract the v1.Status from the JSON API envelop

Directories

Path Synopsis
Package client provides a simple go-client for the k6's REST API.
Package client provides a simple go-client for the k6's REST API.

Jump to

Keyboard shortcuts

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