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

Commit

Permalink
Add call options to client method stubs. (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobr-google authored Jul 7, 2017
1 parent 021498c commit 8134b33
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 5 additions & 3 deletions lib/grpc_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,11 @@ class _GrpcMethod {

void generateClientStub(IndentingWriter out) {
out.println();
out.addBlock('$_clientReturnType $_dartName($_argumentType request) {', '}',
() {
out.println('final call = new ClientCall(_channel, _\$$_dartName);');
out.addBlock(
'$_clientReturnType $_dartName($_argumentType request, {CallOptions options}) {',
'}', () {
out.println(
'final call = new ClientCall(_channel, _\$$_dartName, options: options);');
if (_clientStreaming) {
out.println('request.pipe(call.request);');
} else {
Expand Down
18 changes: 10 additions & 8 deletions test/file_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -545,30 +545,32 @@ class TestClient {
TestClient(this._channel);
ResponseFuture<Output> unary(Input request) {
final call = new ClientCall(_channel, _$unary);
ResponseFuture<Output> unary(Input request, {CallOptions options}) {
final call = new ClientCall(_channel, _$unary, options: options);
call.request
..add(request)
..close();
return new ResponseFuture(call);
}
ResponseFuture<Output> clientStreaming(Stream<Input> request) {
final call = new ClientCall(_channel, _$clientStreaming);
ResponseFuture<Output> clientStreaming(Stream<Input> request,
{CallOptions options}) {
final call = new ClientCall(_channel, _$clientStreaming, options: options);
request.pipe(call.request);
return new ResponseFuture(call);
}
ResponseStream<Output> serverStreaming(Input request) {
final call = new ClientCall(_channel, _$serverStreaming);
ResponseStream<Output> serverStreaming(Input request, {CallOptions options}) {
final call = new ClientCall(_channel, _$serverStreaming, options: options);
call.request
..add(request)
..close();
return new ResponseStream(call);
}
ResponseStream<Output> bidirectional(Stream<Input> request) {
final call = new ClientCall(_channel, _$bidirectional);
ResponseStream<Output> bidirectional(Stream<Input> request,
{CallOptions options}) {
final call = new ClientCall(_channel, _$bidirectional, options: options);
request.pipe(call.request);
return new ResponseStream(call);
}
Expand Down

0 comments on commit 8134b33

Please sign in to comment.