GetEx returns an one-off connection if it's anonymous, otherwise returns existing session with Get.
(id proto.NodeID, isAnonymous bool)
| 195 | // GetEx returns an one-off connection if it's anonymous, otherwise returns existing session |
| 196 | // with Get. |
| 197 | func (p *SessionPool) GetEx(id proto.NodeID, isAnonymous bool) (conn rpc.Client, err error) { |
| 198 | if isAnonymous { |
| 199 | var ( |
| 200 | sess *mux.Session |
| 201 | stream *mux.Stream |
| 202 | ) |
| 203 | if sess, err = newSession(id, true); err != nil { |
| 204 | return |
| 205 | } |
| 206 | if stream, err = sess.OpenStream(); err != nil { |
| 207 | err = errors.Wrapf(err, "open new session to %s failed", id) |
| 208 | return |
| 209 | } |
| 210 | return rpc.NewClient(&oneOffMuxConn{ |
| 211 | sess: sess, |
| 212 | Stream: stream, |
| 213 | }), nil |
| 214 | } |
| 215 | return p.Get(id) |
| 216 | } |
| 217 | |
| 218 | // Remove the node sessions in the pool. |
| 219 | func (p *SessionPool) Remove(id proto.NodeID) { |
nothing calls this directly
no test coverage detected