mirror of
https://github.com/coredns/coredns.git
synced 2026-10-15 23:10:43 -04:00
plugin/grpc: close clients on shutdown (#8582)
This PR closes from the plugin shutdown hook Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -37,6 +37,7 @@ type Proxy struct {
|
||||
addr string
|
||||
|
||||
// connection
|
||||
conn *grpc.ClientConn
|
||||
client pb.DnsServiceClient
|
||||
dialOpts []grpc.DialOption
|
||||
}
|
||||
@@ -66,11 +67,19 @@ func newProxy(addr string, tlsConfig *tls.Config) (*Proxy, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.conn = conn
|
||||
p.client = pb.NewDnsServiceClient(conn)
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (p *Proxy) close() error {
|
||||
if p.conn == nil {
|
||||
return nil
|
||||
}
|
||||
return p.conn.Close()
|
||||
}
|
||||
|
||||
// query sends the request and waits for a response.
|
||||
func (p *Proxy) query(ctx context.Context, req *dns.Msg) (*dns.Msg, error) {
|
||||
start := time.Now()
|
||||
|
||||
Reference in New Issue
Block a user