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

Method Heartbeat

heartbeat.go:55–77  ·  view source on GitHub ↗

Heartbeat sends a heartbeat request to a kafka broker and returns the response.

(ctx context.Context, req *HeartbeatRequest)

Source from the content-addressed store, hash-verified

53
54// Heartbeat sends a heartbeat request to a kafka broker and returns the response.
55func (c *Client) Heartbeat(ctx context.Context, req *HeartbeatRequest) (*HeartbeatResponse, error) {
56 m, err := c.roundTrip(ctx, req.Addr, &heartbeatAPI.Request{
57 GroupID: req.GroupID,
58 GenerationID: req.GenerationID,
59 MemberID: req.MemberID,
60 GroupInstanceID: req.GroupInstanceID,
61 })
62 if err != nil {
63 return nil, fmt.Errorf("kafka.(*Client).Heartbeat: %w", err)
64 }
65
66 res := m.(*heartbeatAPI.Response)
67
68 ret := &HeartbeatResponse{
69 Throttle: makeDuration(res.ThrottleTimeMs),
70 }
71
72 if res.ErrorCode != 0 {
73 ret.Error = Error(res.ErrorCode)
74 }
75
76 return ret, nil
77}
78
79func (t heartbeatRequestV0) size() int32 {
80 return sizeofString(t.GroupID) +

Callers 1

TestClientHeartbeatFunction · 0.80

Calls 3

roundTripMethod · 0.95
makeDurationFunction · 0.85
ErrorTypeAlias · 0.70

Tested by 1

TestClientHeartbeatFunction · 0.64