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

Method FindCoordinator

findcoordinator.go:65–89  ·  view source on GitHub ↗

FindCoordinator sends a findCoordinator request to a kafka broker and returns the response.

(ctx context.Context, req *FindCoordinatorRequest)

Source from the content-addressed store, hash-verified

63// FindCoordinator sends a findCoordinator request to a kafka broker and returns the
64// response.
65func (c *Client) FindCoordinator(ctx context.Context, req *FindCoordinatorRequest) (*FindCoordinatorResponse, error) {
66
67 m, err := c.roundTrip(ctx, req.Addr, &findcoordinator.Request{
68 Key: req.Key,
69 KeyType: int8(req.KeyType),
70 })
71
72 if err != nil {
73 return nil, fmt.Errorf("kafka.(*Client).FindCoordinator: %w", err)
74 }
75
76 res := m.(*findcoordinator.Response)
77 coordinator := &FindCoordinatorResponseCoordinator{
78 NodeID: int(res.NodeID),
79 Host: res.Host,
80 Port: int(res.Port),
81 }
82 ret := &FindCoordinatorResponse{
83 Throttle: makeDuration(res.ThrottleTimeMs),
84 Error: makeError(res.ErrorCode, res.ErrorMessage),
85 Coordinator: coordinator,
86 }
87
88 return ret, nil
89}
90
91// FindCoordinatorRequestV0 requests the coordinator for the specified group or transaction
92//

Callers 1

Calls 3

roundTripMethod · 0.95
makeDurationFunction · 0.85
makeErrorFunction · 0.85

Tested by 1