Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: abort opening client connections quickly while user interrupt program #375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions runner/requester.go
Expand Up @@ -2,6 +2,7 @@ package runner

import (
"context"
"errors"
"fmt"
"math"
"strconv"
Expand All @@ -10,6 +11,7 @@ import (

"github.com/bojand/ghz/load"
"github.com/bojand/ghz/protodesc"

"github.com/jhump/protoreflect/desc"
"github.com/jhump/protoreflect/dynamic"
"github.com/jhump/protoreflect/dynamic/grpcdynamic"
Expand Down Expand Up @@ -159,6 +161,7 @@ func (b *Requester) Run() (*Report, error) {

cc, err := b.openClientConns()
if err != nil {
b.closeClientConns()
return nil, err
}

Expand Down Expand Up @@ -249,6 +252,11 @@ func (b *Requester) openClientConns() ([]*grpc.ClientConn, error) {
}

for n := 0; n < b.config.nConns; n++ {
select {
case <-b.stopCh:
return nil, errors.New("stop while open clients conn")
default:
}
c, err := b.newClientConn(true)
if err != nil {
if b.config.hasLog {
Expand Down