MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / GetEx

Method GetEx

rpc/mux/pool.go:197–216  ·  view source on GitHub ↗

GetEx returns an one-off connection if it's anonymous, otherwise returns existing session with Get.

(id proto.NodeID, isAnonymous bool)

Source from the content-addressed store, hash-verified

195// GetEx returns an one-off connection if it's anonymous, otherwise returns existing session
196// with Get.
197func (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.
219func (p *SessionPool) Remove(id proto.NodeID) {

Callers

nothing calls this directly

Calls 3

GetMethod · 0.95
NewClientFunction · 0.92
newSessionFunction · 0.85

Tested by

no test coverage detected