diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go index 356011dac35a39879979da41a541c3354981c511..db7ce130ffb95291230cfd2dc3029819512bcae3 100644 --- a/cluster/router/chain/chain.go +++ b/cluster/router/chain/chain.go @@ -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,11 @@ 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() { + c.notify <- struct{}{} + }) + c.count++ now := time.Now() if c.count >= countThreshold && now.Sub(c.last) >= timeThreshold {