Server side speedtest implementation (#12750)

This commit is contained in:
Krishna Srinivas
2021-07-27 12:55:56 -07:00
committed by GitHub
parent 471b4fd0c9
commit aa0c28809b
10 changed files with 297 additions and 4 deletions

View File

@@ -969,3 +969,21 @@ func (client *peerRESTClient) GetPeerMetrics(ctx context.Context) (<-chan Metric
}(ch)
return ch, nil
}
func (client *peerRESTClient) Speedtest(ctx context.Context, size, concurrent int, duration time.Duration) (SpeedtestResult, error) {
values := make(url.Values)
values.Set(peerRESTSize, strconv.Itoa(size))
values.Set(peerRESTConcurrent, strconv.Itoa(concurrent))
values.Set(peerRESTDuration, duration.String())
respBody, err := client.callWithContext(context.Background(), peerRESTMethodSpeedtest, values, nil, -1)
if err != nil {
return SpeedtestResult{}, err
}
defer http.DrainBody(respBody)
dec := gob.NewDecoder(respBody)
var result SpeedtestResult
err = dec.Decode(&result)
return result, err
}