Skip to content
This repository was archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
Updated gRPC client stub generation. (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobr-google authored Sep 25, 2017
1 parent 429ffea commit 6c4c55c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

* Avoid name clashes between import prefix and field names.
* Avoid name clashes between generated enum and extension class names.
* Updated gRPC client stub generation to match latest changes to dart-lang/grpc-dart.

## 0.7.6 - 2017-08-22

* Updated gRPC client stub generation to produce code matching latest changes to
dart-lang/dart-grpc.
dart-lang/grpc-dart.

## 0.7.5 - 2017-08-04

Expand Down
9 changes: 3 additions & 6 deletions lib/grpc_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,10 @@ class _GrpcMethod {
out.addBlock(
'$_clientReturnType $_dartName($_argumentType request, {CallOptions options}) {',
'}', () {
final requestStream =
_clientStreaming ? 'request' : 'new Stream.fromIterable([request])';
out.println(
'final call = \$createCall(_\$$_dartName, options: options);');
if (_clientStreaming) {
out.println('request.pipe(call.request);');
} else {
out.println('call.request..add(request)..close();');
}
'final call = \$createCall(_\$$_dartName, $requestStream, options: options);');
if (_serverStreaming) {
out.println('return new ResponseStream(call);');
} else {
Expand Down
19 changes: 7 additions & 12 deletions test/file_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -534,32 +534,27 @@ class TestClient extends Client {
: super(channel, options: options);
ResponseFuture<Output> unary(Input request, {CallOptions options}) {
final call = $createCall(_$unary, options: options);
call.request
..add(request)
..close();
final call = $createCall(_$unary, new Stream.fromIterable([request]),
options: options);
return new ResponseFuture(call);
}
ResponseFuture<Output> clientStreaming(Stream<Input> request,
{CallOptions options}) {
final call = $createCall(_$clientStreaming, options: options);
request.pipe(call.request);
final call = $createCall(_$clientStreaming, request, options: options);
return new ResponseFuture(call);
}
ResponseStream<Output> serverStreaming(Input request, {CallOptions options}) {
final call = $createCall(_$serverStreaming, options: options);
call.request
..add(request)
..close();
final call = $createCall(
_$serverStreaming, new Stream.fromIterable([request]),
options: options);
return new ResponseStream(call);
}
ResponseStream<Output> bidirectional(Stream<Input> request,
{CallOptions options}) {
final call = $createCall(_$bidirectional, options: options);
request.pipe(call.request);
final call = $createCall(_$bidirectional, request, options: options);
return new ResponseStream(call);
}
}
Expand Down

0 comments on commit 6c4c55c

Please sign in to comment.