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

Method heartbeat

conn.go:345–366  ·  view source on GitHub ↗

heartbeat sends a heartbeat message required by consumer groups See http://kafka.apache.org/protocol.html#The_Messages_Heartbeat

(request heartbeatRequestV0)

Source from the content-addressed store, hash-verified

343//
344// See http://kafka.apache.org/protocol.html#The_Messages_Heartbeat
345func (c *Conn) heartbeat(request heartbeatRequestV0) (heartbeatResponseV0, error) {
346 var response heartbeatResponseV0
347
348 err := c.writeOperation(
349 func(deadline time.Time, id int32) error {
350 return c.writeRequest(heartbeat, v0, id, request)
351 },
352 func(deadline time.Time, size int) error {
353 return expectZeroSize(func() (remain int, err error) {
354 return (&response).readFrom(&c.rbuf, size)
355 }())
356 },
357 )
358 if err != nil {
359 return heartbeatResponseV0{}, err
360 }
361 if response.ErrorCode != 0 {
362 return heartbeatResponseV0{}, Error(response.ErrorCode)
363 }
364
365 return response, nil
366}
367
368// joinGroup attempts to join a consumer group
369//

Callers

nothing calls this directly

Calls 5

writeOperationMethod · 0.95
writeRequestMethod · 0.95
expectZeroSizeFunction · 0.85
ErrorTypeAlias · 0.70
readFromMethod · 0.45

Tested by

no test coverage detected