mirror of
https://github.com/coredns/coredns.git
synced 2025-11-29 23:24:26 -05:00
@@ -69,6 +69,8 @@ func New(opts Options) (*Client, error) {
|
||||
return nil, fmt.Errorf("xds: failed to dial balancer {%s}: %v", opts.Config.BalancerName, err)
|
||||
}
|
||||
|
||||
println("dialed balancer at", opts.Config.BalancerName)
|
||||
|
||||
c := &Client{
|
||||
opts: opts,
|
||||
cc: cc,
|
||||
@@ -85,6 +87,10 @@ func (c *Client) Close() {
|
||||
c.cc.Close()
|
||||
}
|
||||
|
||||
func (c *Client) Run() {
|
||||
c.v2c.run()
|
||||
}
|
||||
|
||||
// ServiceUpdate contains update about the service.
|
||||
type ServiceUpdate struct {
|
||||
Cluster string
|
||||
|
||||
@@ -127,12 +127,14 @@ func (v2c *v2Client) run() {
|
||||
}
|
||||
|
||||
retries++
|
||||
println("SENDING STUFF, retries", retries)
|
||||
cli := adsgrpc.NewAggregatedDiscoveryServiceClient(v2c.cc)
|
||||
stream, err := cli.StreamAggregatedResources(v2c.ctx, grpc.WaitForReady(true))
|
||||
stream, err := cli.StreamAggregatedResources(v2c.ctx) //, grpc.WaitForReady(true))
|
||||
if err != nil {
|
||||
log.Infof("xds: ADS stream creation failed: %v", err)
|
||||
continue
|
||||
}
|
||||
println("created ads stream")
|
||||
|
||||
// send() could be blocked on reading updates from the different update
|
||||
// channels when it is not actually sending out messages. So, we need a
|
||||
@@ -143,11 +145,12 @@ func (v2c *v2Client) run() {
|
||||
if v2c.recv(stream) {
|
||||
retries = 0
|
||||
}
|
||||
println("sending has succeeded")
|
||||
close(done)
|
||||
}
|
||||
}
|
||||
|
||||
// sendRequest sends a request for provided typeURL and resource on the provided
|
||||
// endRequest sends a request for provided typeURL and resource on the provided
|
||||
// stream.
|
||||
//
|
||||
// version is the ack version to be sent with the request
|
||||
@@ -261,9 +264,12 @@ func (v2c *v2Client) processAckInfo(t *ackInfo) (target []string, typeURL, versi
|
||||
// on the provided ADS stream.
|
||||
func (v2c *v2Client) send(stream adsStream, done chan struct{}) {
|
||||
if !v2c.sendExisting(stream) {
|
||||
println("not existing stream")
|
||||
return
|
||||
}
|
||||
|
||||
println("in send")
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-v2c.ctx.Done():
|
||||
@@ -278,8 +284,10 @@ func (v2c *v2Client) send(stream adsStream, done chan struct{}) {
|
||||
)
|
||||
switch t := u.(type) {
|
||||
case *watchInfo:
|
||||
println("watchInfo")
|
||||
target, typeURL, version, nonce, send = v2c.processWatchInfo(t)
|
||||
case *ackInfo:
|
||||
println("ackInfo")
|
||||
target, typeURL, version, nonce, send = v2c.processAckInfo(t)
|
||||
}
|
||||
if !send {
|
||||
@@ -367,7 +375,9 @@ func (v2c *v2Client) watchEDS(clusterName string, edsCb edsCallback) (cancel fun
|
||||
}
|
||||
|
||||
func (v2c *v2Client) watch(wi *watchInfo) (cancel func()) {
|
||||
println("watch")
|
||||
v2c.sendCh.Put(wi)
|
||||
println("returning from watch")
|
||||
return func() {
|
||||
v2c.mu.Lock()
|
||||
defer v2c.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user