Skip to content

Commit

Permalink
set time out
Browse files Browse the repository at this point in the history
  • Loading branch information
guozhi.li committed Jul 28, 2023
1 parent fc499e9 commit 8a4f3cc
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions perf-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,24 @@ func (c *clientPerfReader) Read(p []byte) (n int, err error) {

var _ io.Reader = &clientPerfReader{}

const (
// MaxClientPerfTimeout for max time out for client perf
MaxClientPerfTimeout = time.Second * 30
// MinClientPerfTimeout for min time out for client perf
MinClientPerfTimeout = time.Second * 5
)

// ClientPerf - perform net from client to MinIO servers
func (adm *AdminClient) ClientPerf(ctx context.Context) (result ClientPerfResult, err error) {
defer func() {
result.Endpoint = adm.endpointURL.String()
}()
func (adm *AdminClient) ClientPerf(ctx context.Context, dur time.Duration) (result ClientPerfResult, err error) {
if dur > MaxClientPerfTimeout {
dur = MaxClientPerfTimeout
}
if dur < MinClientPerfTimeout {
dur = MinClientPerfTimeout
}
ctx, cancel := context.WithTimeout(ctx, dur)
defer cancel()
result.Endpoint = adm.endpointURL.String()
queryVals := make(url.Values)
reader := &clientPerfReader{}
reader.Start()
Expand Down

0 comments on commit 8a4f3cc

Please sign in to comment.