-
Notifications
You must be signed in to change notification settings - Fork 4k
kvtenant: replace InternalClient with more specific services' client adapters #148486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kvtenant: replace InternalClient with more specific services' client adapters #148486
Conversation
|
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
| } | ||
|
|
||
| func (c *connector) tryForgetClient(ctx context.Context, client kvpb.InternalClient) { | ||
| func (c *connector) tryForgetClient(ctx context.Context, client any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chandra: change this from any to *client
2828ef1 to
f9f4a21
Compare
…adapters
Since we have broken down the `Internal` service into smaller services,
this PR uses them in the tenant connector.
This means the `client.InternalClient` will be replaced by
`RPCTenantServiceClient`, `RPCTenantUsageClient`, and
`RPCTenantSpanConfigClient`, as they are used by the tenant connector. For
gRPC, they can be initialized with the gRPC adapter of `InternalClient`
returned by `NewGRPCInternalClientAdapter`, as these smaller services are a
subset of the `Internal` service.
However, a complication arises with `RPCTenantSpanConfigClient`. We can't
simply use the generic `InternalClient` adapter because its streaming
methods generate request/response types that embed the service name.
For example: Let's take an example here:
`RPCTenantServiceClient` has this method:
```go
TenantSettings(ctx context.Context, in *TenantSettingsRequest) (RPCTenantService_TenantSettingsClient, error)
```
But `NewGRPCInternalClientAdapter` returns `RPCInternalClient`, which
defines:
```go
TenantSettings(ctx context.Context, in *TenantSettingsRequest) (RPCInternal_TenantSettingsClient, error)
```
So they are not compatible, even though `RPCInternal_TenantSettingsClient`
and `RPCTenantService_TenantSettingsClient` are equivalent. The solution
here is to create an adapter that adapts the `InternalClient`
to `RPCTenantServiceClient`.
```go
func (a *grpcInternalToTenantServiceClientAdapter) TenantSettings(
ctx context.Context, in *TenantSettingsRequest,
) (RPCTenantService_TenantSettingsClient, error) {
return (*internalClient)(a).TenantSettings(ctx, in)
}
```
Release note: none
Epic: CRDB-48923
f9f4a21 to
bcd8dd3
Compare
cthumuluru-crdb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
|
TFTR! bors r=cthumuluru-crdb |
Since we have broken down the
Internalservice into smaller services, this PR uses them in the tenant connector.This means the
client.InternalClientwill be replaced byRPCTenantServiceClient,RPCTenantUsageClient, andRPCTenantSpanConfigClient, as they are used by the tenant connector. For gRPC, they can be initialized with the gRPC adapter ofInternalClientreturned byNewGRPCInternalClientAdapter, as these smaller services are a subset of theInternalservice.However, a complication arises with
RPCTenantSpanConfigClient. We can't simply use the genericInternalClientadapter because its streaming methods generate request/response types that embed the service name.For example: Let's take an example here:
RPCTenantServiceClienthas this method:But
NewGRPCInternalClientAdapterreturnsRPCInternalClient, which defines:So they are not compatible, even though
RPCInternal_TenantSettingsClientandRPCTenantService_TenantSettingsClientare equivalent. The solution here is to create an adapter that adapts theInternalClienttoRPCTenantServiceClient.Informs: #148726
Release note: none
Epic: CRDB-48923