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:
Yong Tang
2026-09-29 01:19:28 -07:00
committed by GitHub
parent 594d6c9121
commit d821a74af8
4 changed files with 77 additions and 0 deletions

View File

@@ -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()