InitProducerID sends a initProducerId request to a kafka broker and returns the response.
(ctx context.Context, req *InitProducerIDRequest)
| 59 | // InitProducerID sends a initProducerId request to a kafka broker and returns the |
| 60 | // response. |
| 61 | func (c *Client) InitProducerID(ctx context.Context, req *InitProducerIDRequest) (*InitProducerIDResponse, error) { |
| 62 | m, err := c.roundTrip(ctx, req.Addr, &initproducerid.Request{ |
| 63 | TransactionalID: req.TransactionalID, |
| 64 | TransactionTimeoutMs: int32(req.TransactionTimeoutMs), |
| 65 | ProducerID: int64(req.ProducerID), |
| 66 | ProducerEpoch: int16(req.ProducerEpoch), |
| 67 | }) |
| 68 | if err != nil { |
| 69 | return nil, fmt.Errorf("kafka.(*Client).InitProducerId: %w", err) |
| 70 | } |
| 71 | |
| 72 | res := m.(*initproducerid.Response) |
| 73 | |
| 74 | return &InitProducerIDResponse{ |
| 75 | Producer: &ProducerSession{ |
| 76 | ProducerID: int(res.ProducerID), |
| 77 | ProducerEpoch: int(res.ProducerEpoch), |
| 78 | }, |
| 79 | Throttle: makeDuration(res.ThrottleTimeMs), |
| 80 | Error: makeError(res.ErrorCode, ""), |
| 81 | }, nil |
| 82 | } |