Skip to content

Commit

Permalink
rpadmin: add rack,host,port,uuid info to api_broker
Browse files Browse the repository at this point in the history
This commit adds additional fields to the Broker
struct in api_broker.go. This will be used in
'rpk redpanda admin brokers list' to print those
info additionally.

hoge
  • Loading branch information
daisukebe committed Sep 26, 2024
1 parent a551120 commit 3130a63
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rpadmin/api_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
const (
brokersEndpoint = "/v1/brokers"
brokerEndpoint = "/v1/brokers/%d"
brokerUuids = "/v1/broker_uuids"
)

// MaintenanceStatus is the maintenance status.
Expand Down Expand Up @@ -46,6 +47,9 @@ const (
type Broker struct {
NodeID int `json:"node_id"`
NumCores int `json:"num_cores"`
Rack string `json:"rack"`
InternalAddress string `json:"internal_rpc_address"`
InternalPort int `json:"internal_rpc_port"`
MembershipStatus MembershipStatus `json:"membership_status"`
IsAlive *bool `json:"is_alive"`
Version string `json:"version"`
Expand Down Expand Up @@ -77,6 +81,12 @@ type DecommissionStatusResponse struct {
Partitions []DecommissionPartitions `json:"partitions"`
}

// BrokerUuids is information that shows the mapping of node ID to node UUID.
type BrokerUuids struct {
NodeID int `json:"node_id"`
UUID string `json:"uuid"`
}

// Brokers queries one of the client's hosts and returns the list of brokers.
func (a *AdminAPI) Brokers(ctx context.Context) ([]Broker, error) {
var bs []Broker
Expand Down Expand Up @@ -174,3 +184,9 @@ func (a *AdminAPI) CancelNodePartitionsMovement(ctx context.Context, node int) (
var response []PartitionsMovementResult
return response, a.sendAny(ctx, http.MethodPost, fmt.Sprintf("%s/%d/cancel_partition_moves", brokersEndpoint, node), nil, &response)
}

// BrokerUuids retrieves the mapping of node ID to node UUID.

Check failure on line 188 in rpadmin/api_broker.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported method AdminAPI.GetBrokerUuids should be of the form "GetBrokerUuids ..." (revive)
func (a *AdminAPI) GetBrokerUuids(ctx context.Context) ([]BrokerUuids, error) {
var response []BrokerUuids
return response, a.sendAny(ctx, http.MethodGet, brokerUuids, nil, &response)
}

0 comments on commit 3130a63

Please sign in to comment.