// Metadata sends given metadata request to kafka node and returns related // metadata response. // Calling this method on closed connection will always return ErrClosed. func (c *connection) Metadata(req *proto.MetadataReq) (*proto.MetadataResp, error) { var ok bool if req.CorrelationID, ok = <-c.nextID; !ok { return nil, c.stopErr } if _, err := req.WriteTo(c.conn); err != nil { return nil, err } b, ok := <-c.respc[req.CorrelationID] if !ok { return nil, c.stopErr } return proto.ReadMetadataResp(bytes.NewReader(b)) }
// Metadata sends given metadata request to kafka node and returns related // metadata response. // Calling this method on closed connection will always return ErrClosed. func (c *connection) Metadata(req *proto.MetadataReq) (*proto.MetadataResp, error) { var ok bool if req.CorrelationID, ok = <-c.nextID; !ok { return nil, c.stopErr } respc, err := c.respWaiter(req.CorrelationID) if err != nil { return nil, fmt.Errorf("wait for response: %s", err) } if _, err := req.WriteTo(c.rw); err != nil { c.releaseWaiter(req.CorrelationID) return nil, err } b, ok := <-respc if !ok { return nil, c.stopErr } return proto.ReadMetadataResp(bytes.NewReader(b)) }