Skip to content

Commit

Permalink
Create admin API to list namespaces (temporalio#2170)
Browse files Browse the repository at this point in the history
  • Loading branch information
feedmeapples authored Nov 12, 2021
1 parent 725a4de commit b9edf16
Show file tree
Hide file tree
Showing 10 changed files with 1,368 additions and 308 deletions.
1,396 changes: 1,136 additions & 260 deletions api/adminservice/v1/request_response.pb.go

Large diffs are not rendered by default.

133 changes: 86 additions & 47 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 @@ -245,6 +245,20 @@ func (c *clientImpl) GetReplicationMessages(
return client.GetReplicationMessages(ctx, request, opts...)
}

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

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

func (c *metricClient) ListNamespaces(
ctx context.Context,
request *adminservice.ListNamespacesRequest,
opts ...grpc.CallOption,
) (*adminservice.ListNamespacesResponse, error) {

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

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

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

func (c *metricClient) GetNamespaceReplicationMessages(
ctx context.Context,
request *adminservice.GetNamespaceReplicationMessagesRequest,
Expand Down
16 changes: 16 additions & 0 deletions client/admin/retryableClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,22 @@ func (c *retryableClient) GetReplicationMessages(
return resp, err
}

func (c *retryableClient) ListNamespaces(
ctx context.Context,
request *adminservice.ListNamespacesRequest,
opts ...grpc.CallOption,
) (*adminservice.ListNamespacesResponse, error) {

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

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

0 comments on commit b9edf16

Please sign in to comment.