rapi

package
v1.34.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: Apache-2.0 Imports: 22 Imported by: 2

Documentation

Overview

Remote API to trigger load tests package (REST API).

Index

Constants

View Source
const (
	ModeGRPC = "grpc"
)

Variables

View Source
var (

	// Default percentiles when not otherwise specified.
	DefaultPercentileList []float64
)

Functions

func AddHandlers

func AddHandlers(mux *http.ServeMux, uiPath, datadir string)

AddHandlers adds the REST Api handlers for run, status and stop. uiPath must end with a /.

func AddRun

func AddRun(ro *periodic.RunnerOptions) int64

func DataList

func DataList() (dataList []string)

DataList returns the .json files/entries in data dir.

func Error

func Error(w http.ResponseWriter, msg ErrorReply)

Error writes serialized ErrorReply to the writer.

func FormValue

func FormValue(r *http.Request, json map[string]interface{}, key string) string

FormValue gets the value from the query arguments/url parameter or from the provided map (json data).

func GetConfigAtPath

func GetConfigAtPath(path string, data []byte) (map[string]interface{}, error)

GetConfigAtPath deserializes the bytes as JSON and extracts the map at the given path (only supports simple expression: . is all the json .foo.bar.blah will extract that part of the tree.

func GetDataDir

func GetDataDir() string

func RESTRunHandler

func RESTRunHandler(w http.ResponseWriter, r *http.Request)

RESTRunHandler is api version of UI submit handler.

func RESTStatusHandler

func RESTStatusHandler(w http.ResponseWriter, r *http.Request)

RESTStatusHandler will print the state of the runs.

func RESTStopHandler

func RESTStopHandler(w http.ResponseWriter, r *http.Request)

RESTStopHandler is the api to stop a given run by runid or all the runs if unspecified/0.

func RemoveRun

func RemoveRun(id int64)

func Run

func Run(w http.ResponseWriter, r *http.Request, jd map[string]interface{},
	runner, url string, ro periodic.RunnerOptions, httpopts *fhttp.HTTPOptions,
)

Run executes the run (can be called async or not, writer is nil for async mode).

func SaveJSON

func SaveJSON(name string, json []byte) string

SaveJSON save Json bytes to give file name (.json) in data-path dir.

func SendTSVDataIndex

func SendTSVDataIndex(urlPrefix string, w http.ResponseWriter)

format for gcloud transfer https://cloud.google.com/storage/transfer/create-url-list

func SetDataDir

func SetDataDir(datadir string)

func StopByRunID

func StopByRunID(runid int64) int

StopByRunID stops all the runs if passed 0 or the runid provided.

Types

type ErrorReply

type ErrorReply struct {
	Error     string
	Exception error
}

ErrorReply is returned on errors.

Jump to

Keyboard shortcuts

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