MCPcopy
hub / github.com/bradfitz/gomemcache / dial

Method dial

memcache/memcache.go:269–291  ·  view source on GitHub ↗
(addr net.Addr)

Source from the content-addressed store, hash-verified

267}
268
269func (c *Client) dial(addr net.Addr) (net.Conn, error) {
270 ctx, cancel := context.WithTimeout(context.Background(), c.netTimeout())
271 defer cancel()
272
273 dialerContext := c.DialContext
274 if dialerContext == nil {
275 dialer := net.Dialer{
276 Timeout: c.netTimeout(),
277 }
278 dialerContext = dialer.DialContext
279 }
280
281 nc, err := dialerContext(ctx, addr.Network(), addr.String())
282 if err == nil {
283 return nc, nil
284 }
285
286 if ne, ok := err.(net.Error); ok && ne.Timeout() {
287 return nil, &ConnectTimeoutError{addr}
288 }
289
290 return nil, err
291}
292
293func (c *Client) getConn(addr net.Addr) (*conn, error) {
294 cn, ok := c.getFreeConn(addr)

Callers 1

getConnMethod · 0.95

Calls 3

netTimeoutMethod · 0.95
NetworkMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected