MCPcopy
hub / github.com/grpc/grpc-go / Conn

Method Conn

benchmark/latency/latency.go:84–95  ·  view source on GitHub ↗

Conn returns a net.Conn that wraps c and injects n's latency into that connection. This function also imposes latency for connection creation. If n's Latency is lower than the measured latency in c, an error is returned.

(c net.Conn)

Source from the content-addressed store, hash-verified

82// If n's Latency is lower than the measured latency in c, an error is
83// returned.
84func (n *Network) Conn(c net.Conn) (net.Conn, error) {
85 if n.isLocal() {
86 return c, nil
87 }
88 start := now()
89 nc := &conn{Conn: c, network: n, readBuf: new(bytes.Buffer)}
90 if err := nc.sync(); err != nil {
91 return nil, err
92 }
93 sleep(start.Add(nc.delay).Sub(now()))
94 return nc, nil
95}
96
97type conn struct {
98 net.Conn

Callers 8

TestBufferBloatMethod · 0.95
DialerMethod · 0.95
TimeoutDialerMethod · 0.95
ContextDialerMethod · 0.95
TestConnMethod · 0.80
TestSyncMethod · 0.80
TestSyncTooSlowMethod · 0.80
AcceptMethod · 0.80

Calls 3

isLocalMethod · 0.95
syncMethod · 0.95
AddMethod · 0.65

Tested by 4

TestBufferBloatMethod · 0.76
TestConnMethod · 0.64
TestSyncMethod · 0.64
TestSyncTooSlowMethod · 0.64