EndTxn sends an EndTxn request to a kafka broker and returns its response.
(ctx context.Context, req *EndTxnRequest)
| 40 | |
| 41 | // EndTxn sends an EndTxn request to a kafka broker and returns its response. |
| 42 | func (c *Client) EndTxn(ctx context.Context, req *EndTxnRequest) (*EndTxnResponse, error) { |
| 43 | m, err := c.roundTrip(ctx, req.Addr, &endtxn.Request{ |
| 44 | TransactionalID: req.TransactionalID, |
| 45 | ProducerID: int64(req.ProducerID), |
| 46 | ProducerEpoch: int16(req.ProducerEpoch), |
| 47 | Committed: req.Committed, |
| 48 | }) |
| 49 | if err != nil { |
| 50 | return nil, fmt.Errorf("kafka.(*Client).EndTxn: %w", err) |
| 51 | } |
| 52 | |
| 53 | r := m.(*endtxn.Response) |
| 54 | |
| 55 | res := &EndTxnResponse{ |
| 56 | Throttle: makeDuration(r.ThrottleTimeMs), |
| 57 | Error: makeError(r.ErrorCode, ""), |
| 58 | } |
| 59 | |
| 60 | return res, nil |
| 61 | } |