|
| 1 | +// Copyright 2025 The Cockroach Authors. |
| 2 | +// |
| 3 | +// Use of this software is governed by the CockroachDB Software License |
| 4 | +// included in the /LICENSE file. |
| 5 | + |
| 6 | +package kvpb |
| 7 | + |
| 8 | +import ( |
| 9 | + "context" |
| 10 | + |
| 11 | + grpc "google.golang.org/grpc" |
| 12 | +) |
| 13 | + |
| 14 | +type grpcInternalToTenantServiceClientAdapter internalClient |
| 15 | + |
| 16 | +// NewGRPCInternalToTenantServiceClientAdapter creates a new |
| 17 | +// RPCTenantServiceClient that adapts an InternalClient. This is necessary |
| 18 | +// because the response types for streaming methods like TenantSettings are not |
| 19 | +// compatible between RPCInternal_TenantSettingsClient (of adapter returned by |
| 20 | +// NewGRPCInternalClientAdapter) and RPCTenantService_TenantSettingsClient (of |
| 21 | +// RPCTenantServiceClient), even though they are otherwise equivalent. |
| 22 | +func NewGRPCInternalToTenantServiceClientAdapter(conn *grpc.ClientConn) RPCTenantServiceClient { |
| 23 | + return (*grpcInternalToTenantServiceClientAdapter)(&internalClient{conn}) |
| 24 | +} |
| 25 | + |
| 26 | +func (a *grpcInternalToTenantServiceClientAdapter) TenantSettings( |
| 27 | + ctx context.Context, in *TenantSettingsRequest, |
| 28 | +) (RPCTenantService_TenantSettingsClient, error) { |
| 29 | + return (*internalClient)(a).TenantSettings(ctx, in) |
| 30 | +} |
| 31 | + |
| 32 | +func (a *grpcInternalToTenantServiceClientAdapter) RangeLookup( |
| 33 | + ctx context.Context, in *RangeLookupRequest, |
| 34 | +) (*RangeLookupResponse, error) { |
| 35 | + return (*internalClient)(a).RangeLookup(ctx, in) |
| 36 | +} |
| 37 | + |
| 38 | +func (a *grpcInternalToTenantServiceClientAdapter) GossipSubscription( |
| 39 | + ctx context.Context, in *GossipSubscriptionRequest, |
| 40 | +) (RPCTenantService_GossipSubscriptionClient, error) { |
| 41 | + return (*internalClient)(a).GossipSubscription(ctx, in) |
| 42 | +} |
| 43 | + |
| 44 | +func (a *grpcInternalToTenantServiceClientAdapter) GetRangeDescriptors( |
| 45 | + ctx context.Context, in *GetRangeDescriptorsRequest, |
| 46 | +) (RPCTenantService_GetRangeDescriptorsClient, error) { |
| 47 | + return (*internalClient)(a).GetRangeDescriptors(ctx, in) |
| 48 | +} |
0 commit comments