Documentation ¶
Overview ¶
Copyright 2022 Fortio Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Remote API to trigger load tests package (REST API).
Index ¶
- Constants
- Variables
- func AddDataHandler(mux *http.ServeMux, baseurl, uipath, datadir string)
- func AddHandlers(ahook bincommon.FortioHook, mux *http.ServeMux, ...)
- func DataList() (dataList []string)
- func Error(w http.ResponseWriter, msg string, err error)
- func FormValue(r *http.Request, json map[string]interface{}, key string) string
- func GetConfigAtPath(path string, data []byte) (map[string]interface{}, error)
- func GetDataDir() string
- func GetDataURL(r *http.Request) string
- func ID2URL(r *http.Request, id string) string
- func LogAndFilterDataRequest(h http.Handler) http.Handler
- func NextRunID() int64
- func RESTDNSHandler(w http.ResponseWriter, r *http.Request)
- func RESTRunHandler(w http.ResponseWriter, r *http.Request)
- func RESTStatusHandler(w http.ResponseWriter, r *http.Request)
- func RESTStopHandler(w http.ResponseWriter, r *http.Request)
- func RemoveRun(id int64)
- func Run(w http.ResponseWriter, r *http.Request, jd map[string]interface{}, ...) (periodic.HasRunnerResult, string, []byte, error)
- func RunMetrics() (int, int64)
- func SaveJSON(name string, json []byte) string
- func SendTSVDataIndex(urlPrefix string, w http.ResponseWriter)
- func SetDataDir(datadir string)
- func StopByRunID(runid int64, wait bool) (int, string)
- func UpdateRun(ro *periodic.RunnerOptions) *periodic.Aborter
- type AsyncReply
- type DNSReply
- type StateEnum
- type Status
- type StatusMap
- type StatusReply
Constants ¶
const ( RestRunURI = "rest/run" RestStatusURI = "rest/status" RestStopURI = "rest/stop" RestDNS = "rest/dns" ModeGRPC = "grpc" )
Variables ¶
var ( // Default percentiles when not otherwise specified. DefaultPercentileList []float64 )
Functions ¶
func AddDataHandler ¶ added in v1.35.0
func AddHandlers ¶
func AddHandlers(ahook bincommon.FortioHook, mux *http.ServeMux, baseurl, uiPath, datadir string)
AddHandlers adds the REST Api handlers for run, status and stop. uiPath must end with a /.
func DataList ¶
func DataList() (dataList []string)
DataList returns the .json files/entries in data dir.
func Error ¶
func Error(w http.ResponseWriter, msg string, err error)
Error writes serialized ServerReply marked as error, to the writer.
func FormValue ¶
FormValue gets the value from the query arguments/url parameter or from the provided map (json data).
func GetConfigAtPath ¶
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 GetDataURL ¶ added in v1.35.0
GetDataURL gives the url of the data/ dir either using configured `-base-url` and ui path from the incoming Host header.
func LogAndFilterDataRequest ¶ added in v1.35.0
LogAndFilterDataRequest logs the data request.
func RESTDNSHandler ¶ added in v1.54.0
func RESTDNSHandler(w http.ResponseWriter, r *http.Request)
func RESTRunHandler ¶
func RESTRunHandler(w http.ResponseWriter, r *http.Request)
RESTRunHandler is api version of UI submit handler. TODO: refactor common option/args/flag parsing between uihandler.go and this.
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 Run ¶
func Run(w http.ResponseWriter, r *http.Request, jd map[string]interface{}, runner, url string, ro *periodic.RunnerOptions, httpopts *fhttp.HTTPOptions, htmlMode bool, ) (periodic.HasRunnerResult, string, []byte, error)
Run executes the run (can be called async or not, writer is nil for async mode). Api is a bit awkward to be compatible with both this new now main REST code but also the old one in ui/uihandler.go.
func RunMetrics ¶ added in v1.53.0
RunMetrics returns the number of currently running runs as well as the total runs so far. acquire the lock once (per scrape) for all stats.
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 ¶
StopByRunID stops all the runs if passed 0 or the runid provided. if wait is true, waits for the run to actually end (single only).
func UpdateRun ¶ added in v1.35.0
func UpdateRun(ro *periodic.RunnerOptions) *periodic.Aborter
Must be called exactly once for each runner. Responsible for normalization (abort channel setup) and making sure the options object returned in status is same as the actual one. Note that the Aborter/Stop field is being "moved" into the runner when making the concrete runner and cleared from the original options object so we need to keep our own copy of the aborter pointer. See newPeriodicRunner. Note this is arguably not the best behavior design/could be changed.
Types ¶
type AsyncReply ¶ added in v1.35.0
type AsyncReply struct { jrpc.ServerReply RunID int64 Count int // Object id to retrieve results (only usable if save=on). // Also returned when using stop as long as exactly 1 run is stopped. ResultID string // Result url, constructed from the ResultID and the incoming request URL, if available. ResultURL string }
AsyncReply is returned when async=on is passed.
type DNSReply ¶ added in v1.54.0
type DNSReply struct { jrpc.ServerReply Name string IPv4 []string IPv6 []string }
type Status ¶ added in v1.35.0
type Status struct { RunID int64 State StateEnum RunnerOptions *periodic.RunnerOptions // contains filtered or unexported fields }
type StatusMap ¶ added in v1.35.0
func GetAllRuns ¶ added in v1.35.0
func GetAllRuns() StatusMap
GetAllRuns returns a copy of the status map (note maps are always reference types so no copy is done when returning the map value).
type StatusReply ¶ added in v1.35.0
type StatusReply struct { jrpc.ServerReply Statuses StatusMap }