Skip to content
Snippets Groups Projects
Commit af608d89 authored by 邹毅贤's avatar 邹毅贤
Browse files

trigger init router for first call

parent 068505df
No related branches found
No related tags found
No related merge requests found
...@@ -65,6 +65,8 @@ type RouterChain struct { ...@@ -65,6 +65,8 @@ type RouterChain struct {
notify chan struct{} notify chan struct{}
// Address cache // Address cache
cache atomic.Value cache atomic.Value
// init
init sync.Once
} }
// Route Loop routers in RouterChain and call Route method to determine the target invokers list. // Route Loop routers in RouterChain and call Route method to determine the target invokers list.
...@@ -111,6 +113,11 @@ func (c *RouterChain) SetInvokers(invokers []protocol.Invoker) { ...@@ -111,6 +113,11 @@ func (c *RouterChain) SetInvokers(invokers []protocol.Invoker) {
c.invokers = invokers c.invokers = invokers
c.mutex.Unlock() c.mutex.Unlock()
// it should trigger init router for first call
c.init.Do(func() {
c.notify <- struct{}{}
})
c.count++ c.count++
now := time.Now() now := time.Now()
if c.count >= countThreshold && now.Sub(c.last) >= timeThreshold { if c.count >= countThreshold && now.Sub(c.last) >= timeThreshold {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment