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



##########
File path: cluster/router/chain/chain.go
##########
@@ -109,14 +226,62 @@ func NewRouterChain(url *common.URL) (*RouterChain, 
error) {
        chain := &RouterChain{
                builtinRouters: routers,
                routers:        newRouters,
+               last:           time.Now(),
+               ch:             make(chan struct{}),
        }
        if url != nil {
                chain.url = *url
        }
 
+       go chain.loop()
        return chain, nil
 }
 
+// poolRouter calls poolable router's Pool() to create new address pool and 
address metadata if necessary.
+// If the corresponding cache entry exists, and the poolable router answers no 
need to re-pool (possibly because its
+// rule doesn't change), and the address list doesn't change, then the 
existing data will be re-used.
+func poolRouter(p router.Poolable, origin *InvokerCache, invokers 
[]protocol.Invoker) (router.AddrPool, router.AddrMetadata) {
+       name := p.Name()
+       if isCacheMiss(origin, name) || p.ShouldPool() || 
isInvokersChanged(origin.invokers, invokers) {
+               logger.Debugf("build address cache for router %q", name)
+               return p.Pool(invokers)
+       } else {

Review comment:
       I see. Done.




----------------------------------------------------------------
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