FindCoordinator sends a findCoordinator request to a kafka broker and returns the response.
(ctx context.Context, req *FindCoordinatorRequest)
| 63 | // FindCoordinator sends a findCoordinator request to a kafka broker and returns the |
| 64 | // response. |
| 65 | func (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 | // |