MCPcopy
hub / github.com/dgraph-io/dgraph / Connect

Method Connect

conn/pool.go:153–175  ·  view source on GitHub ↗

Connect creates a Pool instance for the node with the given address or returns the existing one.

(addr string, tlsClientConf *tls.Config)

Source from the content-addressed store, hash-verified

151
152// Connect creates a Pool instance for the node with the given address or returns the existing one.
153func (p *Pools) Connect(addr string, tlsClientConf *tls.Config) *Pool {
154 existingPool, has := p.getPool(addr)
155 if has {
156 return existingPool
157 }
158
159 pool, err := newPool(addr, tlsClientConf)
160 if err != nil {
161 glog.Errorf("CONN: Unable to connect to host: %s", addr)
162 return nil
163 }
164
165 p.Lock()
166 defer p.Unlock()
167 existingPool, has = p.all[addr]
168 if has {
169 go pool.shutdown() // Not being used, so release the resources.
170 return existingPool
171 }
172 glog.Infof("CONN: Connecting to %s\n", addr)
173 p.all[addr] = pool
174 return pool
175}
176
177// newPool creates a new "pool" with one gRPC connection, refcount 0.
178func newPool(addr string, tlsClientConf *tls.Config) (*Pool, error) {

Callers

nothing calls this directly

Calls 7

getPoolMethod · 0.95
newPoolFunction · 0.85
shutdownMethod · 0.80
InfofMethod · 0.80
ErrorfMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected