Why there is no abstract class for client? why expose `$...` methods?
Open
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 572
- Forks
- 196
- Avg merge
- 1h 59m
- Merged PRs (30d)
- 2
Description
Assume a following proto:
service MerchantService {
rpc Search(MerchantSearchRequest) returns (MerchantSearchResponse);
}
Current plugin generates following client code:
class MerchantServiceClient extends $grpc.Client {
MerchantServiceClient($grpc.ClientChannel channel,
{$grpc.CallOptions? options,
$core.Iterable<$grpc.ClientInterceptor>? interceptors})
: super(channel, options: options,
interceptors: interceptors);
$grpc.ResponseFuture<$0.MerchantSearchResponse> search($0.MerchantSearchRequest request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$search, request, options: options);
}
}
It defines a search method that is expected to be used by the users, but it also exposes methods from $grpc.Client that are not expected to be used by them.
How about to generate something like:
abstract class MerchantServiceClient {
$grpc.ResponseFuture<$0.MerchantSearchResponse> search($0.MerchantSearchRequest request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$search, request, options: options);
}
}
class _MerchantServiceClient extends $grpc.Client implements MerchantServiceClient {
MerchantServiceClient($grpc.ClientChannel channel,
{$grpc.CallOptions? options,
$core.Iterable<$grpc.ClientInterceptor>? interceptors})
: super(channel, options: options,
interceptors: interceptors);
$grpc.ResponseFuture<$0.MerchantSearchResponse> search($0.MerchantSearchRequest request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$search, request, options: options);
}
}
MerchantServiceClient createMerchantServiceClient($grpc.ClientChannel channel,
{$grpc.CallOptions? options,
$core.Iterable<$grpc.ClientInterceptor>? interceptors}) {
return MerchantServiceClient(channel,
options: options, interceptors: interceptors);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no generator file, test, or entry point. First identify the Dart client-generation template and its related tests, then determine whether the proposed abstract client, private implementation, and factory define the intended completion criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100