TimeoutDialer returns a TimeoutDialer that wraps d and injects n's latency in its connections. n's Latency is also injected to the connection's creation.
(d TimeoutDialer)
| 291 | // in its connections. n's Latency is also injected to the connection's |
| 292 | // creation. |
| 293 | func (n *Network) TimeoutDialer(d TimeoutDialer) TimeoutDialer { |
| 294 | if n.isLocal() { |
| 295 | return d |
| 296 | } |
| 297 | return func(network, address string, timeout time.Duration) (net.Conn, error) { |
| 298 | conn, err := d(network, address, timeout) |
| 299 | if err != nil { |
| 300 | return nil, err |
| 301 | } |
| 302 | return n.Conn(conn) |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | // ContextDialer returns a ContextDialer that wraps d and injects n's latency |
| 307 | // in its connections. n's Latency is also injected to the connection's |