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

Trigger init router for first call

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