github.com/segmentio/kafka-go@v0.4.48-0.20240318174348-3f6244eb34fd/protocol/createpartitions/createpartitions.go (about)

     1  package createpartitions
     2  
     3  import "github.com/segmentio/kafka-go/protocol"
     4  
     5  func init() {
     6  	protocol.Register(&Request{}, &Response{})
     7  }
     8  
     9  // Detailed API definition: https://kafka.apache.org/protocol#The_Messages_CreatePartitions.
    10  // TODO: Support version 2.
    11  type Request struct {
    12  	Topics       []RequestTopic `kafka:"min=v0,max=v1"`
    13  	TimeoutMs    int32          `kafka:"min=v0,max=v1"`
    14  	ValidateOnly bool           `kafka:"min=v0,max=v1"`
    15  }
    16  
    17  func (r *Request) ApiKey() protocol.ApiKey { return protocol.CreatePartitions }
    18  
    19  func (r *Request) Broker(cluster protocol.Cluster) (protocol.Broker, error) {
    20  	return cluster.Brokers[cluster.Controller], nil
    21  }
    22  
    23  type RequestTopic struct {
    24  	Name        string              `kafka:"min=v0,max=v1"`
    25  	Count       int32               `kafka:"min=v0,max=v1"`
    26  	Assignments []RequestAssignment `kafka:"min=v0,max=v1,nullable"`
    27  }
    28  
    29  type RequestAssignment struct {
    30  	BrokerIDs []int32 `kafka:"min=v0,max=v1"`
    31  }
    32  
    33  type Response struct {
    34  	ThrottleTimeMs int32            `kafka:"min=v0,max=v1"`
    35  	Results        []ResponseResult `kafka:"min=v0,max=v1"`
    36  }
    37  
    38  func (r *Response) ApiKey() protocol.ApiKey { return protocol.CreatePartitions }
    39  
    40  type ResponseResult struct {
    41  	Name         string `kafka:"min=v0,max=v1"`
    42  	ErrorCode    int16  `kafka:"min=v0,max=v1"`
    43  	ErrorMessage string `kafka:"min=v0,max=v1,nullable"`
    44  }
    45  
    46  var _ protocol.BrokerMessage = (*Request)(nil)