MCPcopy
hub / github.com/segmentio/kafka-go / Write

Method Write

conn_test.go:57–74  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

55}
56
57func (c *connPipe) Write(b []byte) (int, error) {
58 // The nettest/ConcurrentMethods test spawns a bunch of goroutines that do
59 // random stuff on the connection, if a Read or Write was issued before a
60 // deadline was set then it could cancel an inflight request to kafka,
61 // resulting in the connection being closed.
62 // To prevent this from happening we wait a little while to give the other
63 // goroutines a chance to start and set the deadline.
64 time.Sleep(time.Millisecond)
65
66 // The nettest code only sets deadlines when it expects the write to time
67 // out. The broker connection is alive and able to accept data, so we need
68 // to simulate the timeout in order to get the tests to pass.
69 if t := c.wconn.writeDeadline(); !t.IsZero() {
70 return 0, &timeout{}
71 }
72
73 return c.wconn.Write(b)
74}
75
76func (c *connPipe) LocalAddr() net.Addr {
77 return c.rconn.LocalAddr()

Callers 12

CloseMethod · 0.45
testConnWriteFunction · 0.45
testConnCloseAndWriteFunction · 0.45
testConnSeekFirstOffsetFunction · 0.45
testConnSeekLastOffsetFunction · 0.45
testConnSeekRandomOffsetFunction · 0.45
testConnSeekDontCheckFunction · 0.45
testConnReadShortBufferFunction · 0.45
benchmarkConnWriteFunction · 0.45

Calls 2

writeDeadlineMethod · 0.80
IsZeroMethod · 0.80

Tested by

no test coverage detected