Skip to content

Commit

Permalink
Add admin api to list all cluster information (#2377)
Browse files Browse the repository at this point in the history
* Add admin api to list all cluster information
  • Loading branch information
yux0 authored Jan 13, 2022
1 parent 72e5b67 commit eb95443
Show file tree
Hide file tree
Showing 13 changed files with 1,069 additions and 263 deletions.
968 changes: 763 additions & 205 deletions api/adminservice/v1/request_response.pb.go

Large diffs are not rendered by default.

150 changes: 95 additions & 55 deletions api/adminservice/v1/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions api/adminservicemock/v1/service.pb.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions client/admin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,20 @@ func (c *clientImpl) DescribeCluster(
return client.DescribeCluster(ctx, request, opts...)
}

func (c *clientImpl) ListClusters(
ctx context.Context,
request *adminservice.ListClustersRequest,
opts ...grpc.CallOption,
) (*adminservice.ListClustersResponse, error) {
client, err := c.getRandomClient()
if err != nil {
return nil, err
}
ctx, cancel := c.createContext(ctx)
defer cancel()
return client.ListClusters(ctx, request, opts...)
}

func (c *clientImpl) ListClusterMembers(
ctx context.Context,
request *adminservice.ListClusterMembersRequest,
Expand Down
18 changes: 18 additions & 0 deletions client/admin/metricClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,24 @@ func (c *metricClient) DescribeCluster(
return resp, err
}

func (c *metricClient) ListClusters(
ctx context.Context,
request *adminservice.ListClustersRequest,
opts ...grpc.CallOption,
) (*adminservice.ListClustersResponse, error) {

c.metricsClient.IncCounter(metrics.AdminClientListClustersScope, metrics.ClientRequests)

sw := c.metricsClient.StartTimer(metrics.AdminClientListClustersScope, metrics.ClientLatency)
resp, err := c.client.ListClusters(ctx, request, opts...)
sw.Stop()

if err != nil {
c.metricsClient.IncCounter(metrics.AdminClientListClustersScope, metrics.ClientFailures)
}
return resp, err
}

func (c *metricClient) ListClusterMembers(
ctx context.Context,
request *adminservice.ListClusterMembersRequest,
Expand Down
17 changes: 17 additions & 0 deletions client/admin/retryableClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,23 @@ func (c *retryableClient) DescribeCluster(
err := backoff.Retry(op, c.policy, c.isRetryable)
return resp, err
}

func (c *retryableClient) ListClusters(
ctx context.Context,
request *adminservice.ListClustersRequest,
opts ...grpc.CallOption,
) (*adminservice.ListClustersResponse, error) {

var resp *adminservice.ListClustersResponse
op := func() error {
var err error
resp, err = c.client.ListClusters(ctx, request, opts...)
return err
}
err := backoff.Retry(op, c.policy, c.isRetryable)
return resp, err
}

func (c *retryableClient) ListClusterMembers(
ctx context.Context,
request *adminservice.ListClusterMembersRequest,
Expand Down
Loading

0 comments on commit eb95443

Please sign in to comment.