mirror of
https://github.com/coredns/coredns.git
synced 2025-12-08 19:35:10 -05:00
Dedup policy implement between grpc and proxy plugin (#3537)
Signed-off-by: zouyee <zounengren@cmss.chinamobile.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/coredns/coredns/plugin"
|
||||
"github.com/coredns/coredns/plugin/debug"
|
||||
"github.com/coredns/coredns/plugin/pkg/policy"
|
||||
"github.com/coredns/coredns/request"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
@@ -17,7 +18,7 @@ import (
|
||||
// It has a list of proxies each representing one upstream proxy.
|
||||
type GRPC struct {
|
||||
proxies []*Proxy
|
||||
p Policy
|
||||
p policy.Policy
|
||||
|
||||
from string
|
||||
ignored []string
|
||||
@@ -93,7 +94,7 @@ func (g *GRPC) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
|
||||
// NewGRPC returns a new GRPC.
|
||||
func newGRPC() *GRPC {
|
||||
g := &GRPC{
|
||||
p: new(random),
|
||||
p: new(policy.Random),
|
||||
}
|
||||
return g
|
||||
}
|
||||
@@ -126,6 +127,11 @@ func (g *GRPC) isAllowedDomain(name string) bool {
|
||||
}
|
||||
|
||||
// List returns a set of proxies to be used for this client depending on the policy in p.
|
||||
func (g *GRPC) list() []*Proxy { return g.p.List(g.proxies) }
|
||||
func (g *GRPC) list() []*Proxy {
|
||||
if len(g.p.List(g.proxies)) == 1 {
|
||||
return g.p.List(g.proxies)[0].([]*Proxy)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
const defaultTimeout = 5 * time.Second
|
||||
|
||||
Reference in New Issue
Block a user