cvictory commented on a change in pull request #708:
URL: https://github.com/apache/dubbo-go/pull/708#discussion_r475408136



##########
File path: cluster/router/chain/chain.go
##########
@@ -88,6 +104,116 @@ func (c *RouterChain) AddRouters(routers 
[]router.PriorityRouter) {
        c.routers = newRouters
 }
 
+// SetInvokers receives updated invokers from registry center. If the times of 
notification exceeds countThreshold and
+// time interval exceeds timeThreshold since last cache update, then notify to 
update the cache.
+func (c *RouterChain) SetInvokers(invokers []protocol.Invoker) {
+       c.mutex.Lock()
+       c.invokers = invokers
+       c.mutex.Unlock()
+
+       c.count++
+       now := time.Now()
+       if c.count >= countThreshold && now.Sub(c.last) >= timeThreshold {

Review comment:
       If the data from registry is changed once, it will not notify to 
c.notify.  
   
   And it will build cache when it is timeout or receive notify channel.  The 
worst situation is that it cannot build cache after 5 seconds.
   
   ```
   //cluster/router/chain/chain.go:127
        for {
                ticker := time.NewTicker(timeInterval)
                select {
                case <-ticker.C:
                        c.buildCache()
                case <-c.notify:
                        c.buildCache()
                }
        }
   ```
   It can't be build cache as soon as possible. 
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to