Skip to content

Commit

Permalink
grpc graceful shotdown on Bind
Browse files Browse the repository at this point in the history
grpc graceful shotdown on Bind
  • Loading branch information
oke11o committed Sep 29, 2023
1 parent 388f6e4 commit d0d396f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions components/guns/grpc/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func NewGun(conf GunConfig) *Gun {
func (g *Gun) Bind(aggr core.Aggregator, deps core.GunDeps) error {
conn, err := makeGRPCConnect(g.conf.Target, g.conf.TLS, g.conf.DialOptions)
if err != nil {
log.Fatalf("FATAL: grpc.Dial failed\n %s\n", err)
return fmt.Errorf("makeGRPCConnect fail %w", err)
}
g.client = conn
g.aggr = aggr
Expand Down Expand Up @@ -223,15 +223,15 @@ func makeGRPCConnect(target string, isTLS bool, dialOptions grpcDialOptions) (co
if dialOptions.Timeout != 0 {
timeout = dialOptions.Timeout
}
opts = append(opts, grpc.WithTimeout(timeout))
opts = append(opts, grpc.WithUserAgent("load test, pandora universal grpc shooter"))

if dialOptions.Authority != "" {
opts = append(opts, grpc.WithAuthority(dialOptions.Authority))
}

conn, err = grpc.Dial(target, opts...)
return
ctx, cncl := context.WithTimeout(context.Background(), timeout)
defer cncl()
return grpc.DialContext(ctx, target, opts...)
}

func convertGrpcStatus(err error) int {
Expand Down

0 comments on commit d0d396f

Please sign in to comment.