-
Notifications
You must be signed in to change notification settings - Fork 195
Disambiguate names of service methods in grpc output #487
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,18 @@ class TestClient extends $grpc.Client { | |
'/Test/Bidirectional', | ||
($0.Input value) => value.writeToBuffer(), | ||
($core.List<$core.int> value) => $0.Output.fromBuffer(value)); | ||
static final _$new_ = $grpc.ClientMethod<$0.Input, $0.Output>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing I was curious of, is it possible to have a name collision with the library import aliases? i.e. do we also need to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $ cannot occur in a protobuf identifier, (https://developers.google.com/protocol-buffers/docs/reference/proto3-spec#identifiers) - I also tried it out and the protoc compiler gave a syntax error. I believe that is why we chose to use $ in the first place for these names. That means we could actually remove all the reserved words with $! I won't do that in this PR to keep the scope smaller. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I removed it from those added). |
||
'/Test/New', | ||
($0.Input value) => value.writeToBuffer(), | ||
($core.List<$core.int> value) => $0.Output.fromBuffer(value)); | ||
static final _$$addMethod_ = $grpc.ClientMethod<$0.Input, $0.Output>( | ||
'/Test/$addMethod', | ||
($0.Input value) => value.writeToBuffer(), | ||
($core.List<$core.int> value) => $0.Output.fromBuffer(value)); | ||
static final _$x32SillyName_ = $grpc.ClientMethod<$0.Input, $0.Output>( | ||
'/Test/_32SillyName', | ||
($0.Input value) => value.writeToBuffer(), | ||
($core.List<$core.int> value) => $0.Output.fromBuffer(value)); | ||
|
||
TestClient($grpc.ClientChannel channel, | ||
{$grpc.CallOptions? options, | ||
|
@@ -59,6 +71,21 @@ class TestClient extends $grpc.Client { | |
{$grpc.CallOptions? options}) { | ||
return $createStreamingCall(_$bidirectional, request, options: options); | ||
} | ||
|
||
$grpc.ResponseFuture<$0.Output> new_($0.Input request, | ||
{$grpc.CallOptions? options}) { | ||
return $createUnaryCall(_$new_, request, options: options); | ||
} | ||
|
||
$grpc.ResponseFuture<$0.Output> $addMethod_($0.Input request, | ||
{$grpc.CallOptions? options}) { | ||
return $createUnaryCall(_$$addMethod_, request, options: options); | ||
} | ||
|
||
$grpc.ResponseFuture<$0.Output> x32SillyName_($0.Input request, | ||
{$grpc.CallOptions? options}) { | ||
return $createUnaryCall(_$x32SillyName_, request, options: options); | ||
} | ||
} | ||
|
||
abstract class TestServiceBase extends $grpc.Service { | ||
|
@@ -93,6 +120,27 @@ abstract class TestServiceBase extends $grpc.Service { | |
true, | ||
($core.List<$core.int> value) => $0.Input.fromBuffer(value), | ||
($0.Output value) => value.writeToBuffer())); | ||
$addMethod($grpc.ServiceMethod<$0.Input, $0.Output>( | ||
'New', | ||
new__Pre, | ||
false, | ||
false, | ||
($core.List<$core.int> value) => $0.Input.fromBuffer(value), | ||
($0.Output value) => value.writeToBuffer())); | ||
$addMethod($grpc.ServiceMethod<$0.Input, $0.Output>( | ||
'$addMethod', | ||
$addMethod__Pre, | ||
false, | ||
false, | ||
($core.List<$core.int> value) => $0.Input.fromBuffer(value), | ||
($0.Output value) => value.writeToBuffer())); | ||
$addMethod($grpc.ServiceMethod<$0.Input, $0.Output>( | ||
'_32SillyName', | ||
x32SillyName__Pre, | ||
false, | ||
false, | ||
($core.List<$core.int> value) => $0.Input.fromBuffer(value), | ||
($0.Output value) => value.writeToBuffer())); | ||
} | ||
|
||
$async.Future<$0.Output> unary_Pre( | ||
|
@@ -105,11 +153,31 @@ abstract class TestServiceBase extends $grpc.Service { | |
yield* serverStreaming(call, await request); | ||
} | ||
|
||
$async.Future<$0.Output> new__Pre( | ||
$grpc.ServiceCall call, $async.Future<$0.Input> request) async { | ||
return new_(call, await request); | ||
} | ||
|
||
$async.Future<$0.Output> $addMethod__Pre( | ||
$grpc.ServiceCall call, $async.Future<$0.Input> request) async { | ||
return $addMethod_(call, await request); | ||
} | ||
|
||
$async.Future<$0.Output> x32SillyName__Pre( | ||
$grpc.ServiceCall call, $async.Future<$0.Input> request) async { | ||
return x32SillyName_(call, await request); | ||
} | ||
|
||
$async.Future<$0.Output> unary($grpc.ServiceCall call, $0.Input request); | ||
$async.Future<$0.Output> clientStreaming( | ||
$grpc.ServiceCall call, $async.Stream<$0.Input> request); | ||
$async.Stream<$0.Output> serverStreaming( | ||
$grpc.ServiceCall call, $0.Input request); | ||
$async.Stream<$0.Output> bidirectional( | ||
$grpc.ServiceCall call, $async.Stream<$0.Input> request); | ||
$async.Future<$0.Output> new_($grpc.ServiceCall call, $0.Input request); | ||
$async.Future<$0.Output> $addMethod_( | ||
$grpc.ServiceCall call, $0.Input request); | ||
$async.Future<$0.Output> x32SillyName_( | ||
$grpc.ServiceCall call, $0.Input request); | ||
} |
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.
Can this be
const
? Also, do we need the explicit type on the left-hand side?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.
yes!
Done - also in surrounding code.