shufflePool swaps randomly elements in the server pool The `offset` value indicates that the shuffling should start at this offset and leave the elements from [0..offset) intact.
(offset int)
| 2136 | // The `offset` value indicates that the shuffling should start at |
| 2137 | // this offset and leave the elements from [0..offset) intact. |
| 2138 | func (nc *Conn) shufflePool(offset int) { |
| 2139 | if len(nc.srvPool) <= offset+1 { |
| 2140 | return |
| 2141 | } |
| 2142 | source := rand.NewSource(time.Now().UnixNano()) |
| 2143 | r := rand.New(source) |
| 2144 | for i := offset; i < len(nc.srvPool); i++ { |
| 2145 | j := offset + r.Intn(i+1-offset) |
| 2146 | nc.srvPool[i], nc.srvPool[j] = nc.srvPool[j], nc.srvPool[i] |
| 2147 | } |
| 2148 | } |
| 2149 | |
| 2150 | func (nc *Conn) newReaderWriter() { |
| 2151 | nc.br = &natsReader{ |
no outgoing calls
no test coverage detected