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
api, core, services: make ProtoReflectionService interceptor compatible #6967
Merged
voidzcy
merged 16 commits into
grpc:master
from
voidzcy:bugfix/make_proto_reflection_service_interceptable
May 1, 2020
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4f7462d
Eliminate InternalNotifyOnServerBuilder interface.
voidzcy 7d8547a
Expose server reference on ServerCall interface.
voidzcy 1952927
Add getServer() API implementation to subclasses.
voidzcy 5b51f87
Obtain server via a server interceptor.
voidzcy 9273cdd
Eliminate callback for server build.
voidzcy d268012
Add default implementation for ServerCall.getServer().
voidzcy 933d099
Add ExperimentalApi annotation.
voidzcy 130adde
Remove comment requirement for using one reflection service instance …
voidzcy f50789b
Add a simple test case covering a single reflection service instance …
voidzcy acb2a44
Use explicit lock
voidzcy 19fd730
Put server into Context.
voidzcy b0d15a6
Add an internal accessor for accessing the Context key.
voidzcy d3935fa
Change ProtoReflectionService to obtain Server from Context.
voidzcy e4a6b9b
Revert changes for exposing Server via ServerCall.
voidzcy 9a979c5
Move the Context key definition and accessor to io.grpc.
voidzcy 6277cac
Makee context key package private.
voidzcy File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
288 changes: 288 additions & 0 deletions
288
...ces/src/generated/test/grpc/io/grpc/reflection/testing/AnotherReflectableServiceGrpc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,288 @@ | ||
package io.grpc.reflection.testing; | ||
|
||
import static io.grpc.MethodDescriptor.generateFullMethodName; | ||
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; | ||
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; | ||
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; | ||
import static io.grpc.stub.ClientCalls.asyncUnaryCall; | ||
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; | ||
import static io.grpc.stub.ClientCalls.blockingUnaryCall; | ||
import static io.grpc.stub.ClientCalls.futureUnaryCall; | ||
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; | ||
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; | ||
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; | ||
import static io.grpc.stub.ServerCalls.asyncUnaryCall; | ||
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; | ||
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; | ||
|
||
/** | ||
*/ | ||
@javax.annotation.Generated( | ||
value = "by gRPC proto compiler", | ||
comments = "Source: io/grpc/reflection/testing/reflection_test.proto") | ||
public final class AnotherReflectableServiceGrpc { | ||
|
||
private AnotherReflectableServiceGrpc() {} | ||
|
||
public static final String SERVICE_NAME = "grpc.reflection.testing.AnotherReflectableService"; | ||
|
||
// Static method descriptors that strictly reflect the proto. | ||
private static volatile io.grpc.MethodDescriptor<io.grpc.reflection.testing.Request, | ||
io.grpc.reflection.testing.Reply> getMethodMethod; | ||
|
||
@io.grpc.stub.annotations.RpcMethod( | ||
fullMethodName = SERVICE_NAME + '/' + "Method", | ||
requestType = io.grpc.reflection.testing.Request.class, | ||
responseType = io.grpc.reflection.testing.Reply.class, | ||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY) | ||
public static io.grpc.MethodDescriptor<io.grpc.reflection.testing.Request, | ||
io.grpc.reflection.testing.Reply> getMethodMethod() { | ||
io.grpc.MethodDescriptor<io.grpc.reflection.testing.Request, io.grpc.reflection.testing.Reply> getMethodMethod; | ||
if ((getMethodMethod = AnotherReflectableServiceGrpc.getMethodMethod) == null) { | ||
synchronized (AnotherReflectableServiceGrpc.class) { | ||
if ((getMethodMethod = AnotherReflectableServiceGrpc.getMethodMethod) == null) { | ||
AnotherReflectableServiceGrpc.getMethodMethod = getMethodMethod = | ||
io.grpc.MethodDescriptor.<io.grpc.reflection.testing.Request, io.grpc.reflection.testing.Reply>newBuilder() | ||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY) | ||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "Method")) | ||
.setSampledToLocalTracing(true) | ||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( | ||
io.grpc.reflection.testing.Request.getDefaultInstance())) | ||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( | ||
io.grpc.reflection.testing.Reply.getDefaultInstance())) | ||
.setSchemaDescriptor(new AnotherReflectableServiceMethodDescriptorSupplier("Method")) | ||
.build(); | ||
} | ||
} | ||
} | ||
return getMethodMethod; | ||
} | ||
|
||
/** | ||
* Creates a new async stub that supports all call types for the service | ||
*/ | ||
public static AnotherReflectableServiceStub newStub(io.grpc.Channel channel) { | ||
io.grpc.stub.AbstractStub.StubFactory<AnotherReflectableServiceStub> factory = | ||
new io.grpc.stub.AbstractStub.StubFactory<AnotherReflectableServiceStub>() { | ||
@java.lang.Override | ||
public AnotherReflectableServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { | ||
return new AnotherReflectableServiceStub(channel, callOptions); | ||
} | ||
}; | ||
return AnotherReflectableServiceStub.newStub(factory, channel); | ||
} | ||
|
||
/** | ||
* Creates a new blocking-style stub that supports unary and streaming output calls on the service | ||
*/ | ||
public static AnotherReflectableServiceBlockingStub newBlockingStub( | ||
io.grpc.Channel channel) { | ||
io.grpc.stub.AbstractStub.StubFactory<AnotherReflectableServiceBlockingStub> factory = | ||
new io.grpc.stub.AbstractStub.StubFactory<AnotherReflectableServiceBlockingStub>() { | ||
@java.lang.Override | ||
public AnotherReflectableServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { | ||
return new AnotherReflectableServiceBlockingStub(channel, callOptions); | ||
} | ||
}; | ||
return AnotherReflectableServiceBlockingStub.newStub(factory, channel); | ||
} | ||
|
||
/** | ||
* Creates a new ListenableFuture-style stub that supports unary calls on the service | ||
*/ | ||
public static AnotherReflectableServiceFutureStub newFutureStub( | ||
io.grpc.Channel channel) { | ||
io.grpc.stub.AbstractStub.StubFactory<AnotherReflectableServiceFutureStub> factory = | ||
new io.grpc.stub.AbstractStub.StubFactory<AnotherReflectableServiceFutureStub>() { | ||
@java.lang.Override | ||
public AnotherReflectableServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { | ||
return new AnotherReflectableServiceFutureStub(channel, callOptions); | ||
} | ||
}; | ||
return AnotherReflectableServiceFutureStub.newStub(factory, channel); | ||
} | ||
|
||
/** | ||
*/ | ||
public static abstract class AnotherReflectableServiceImplBase implements io.grpc.BindableService { | ||
|
||
/** | ||
*/ | ||
public void method(io.grpc.reflection.testing.Request request, | ||
io.grpc.stub.StreamObserver<io.grpc.reflection.testing.Reply> responseObserver) { | ||
asyncUnimplementedUnaryCall(getMethodMethod(), responseObserver); | ||
} | ||
|
||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { | ||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) | ||
.addMethod( | ||
getMethodMethod(), | ||
asyncUnaryCall( | ||
new MethodHandlers< | ||
io.grpc.reflection.testing.Request, | ||
io.grpc.reflection.testing.Reply>( | ||
this, METHODID_METHOD))) | ||
.build(); | ||
} | ||
} | ||
|
||
/** | ||
*/ | ||
public static final class AnotherReflectableServiceStub extends io.grpc.stub.AbstractAsyncStub<AnotherReflectableServiceStub> { | ||
private AnotherReflectableServiceStub( | ||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) { | ||
super(channel, callOptions); | ||
} | ||
|
||
@java.lang.Override | ||
protected AnotherReflectableServiceStub build( | ||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) { | ||
return new AnotherReflectableServiceStub(channel, callOptions); | ||
} | ||
|
||
/** | ||
*/ | ||
public void method(io.grpc.reflection.testing.Request request, | ||
io.grpc.stub.StreamObserver<io.grpc.reflection.testing.Reply> responseObserver) { | ||
asyncUnaryCall( | ||
getChannel().newCall(getMethodMethod(), getCallOptions()), request, responseObserver); | ||
} | ||
} | ||
|
||
/** | ||
*/ | ||
public static final class AnotherReflectableServiceBlockingStub extends io.grpc.stub.AbstractBlockingStub<AnotherReflectableServiceBlockingStub> { | ||
private AnotherReflectableServiceBlockingStub( | ||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) { | ||
super(channel, callOptions); | ||
} | ||
|
||
@java.lang.Override | ||
protected AnotherReflectableServiceBlockingStub build( | ||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) { | ||
return new AnotherReflectableServiceBlockingStub(channel, callOptions); | ||
} | ||
|
||
/** | ||
*/ | ||
public io.grpc.reflection.testing.Reply method(io.grpc.reflection.testing.Request request) { | ||
return blockingUnaryCall( | ||
getChannel(), getMethodMethod(), getCallOptions(), request); | ||
} | ||
} | ||
|
||
/** | ||
*/ | ||
public static final class AnotherReflectableServiceFutureStub extends io.grpc.stub.AbstractFutureStub<AnotherReflectableServiceFutureStub> { | ||
private AnotherReflectableServiceFutureStub( | ||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) { | ||
super(channel, callOptions); | ||
} | ||
|
||
@java.lang.Override | ||
protected AnotherReflectableServiceFutureStub build( | ||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) { | ||
return new AnotherReflectableServiceFutureStub(channel, callOptions); | ||
} | ||
|
||
/** | ||
*/ | ||
public com.google.common.util.concurrent.ListenableFuture<io.grpc.reflection.testing.Reply> method( | ||
io.grpc.reflection.testing.Request request) { | ||
return futureUnaryCall( | ||
getChannel().newCall(getMethodMethod(), getCallOptions()), request); | ||
} | ||
} | ||
|
||
private static final int METHODID_METHOD = 0; | ||
|
||
private static final class MethodHandlers<Req, Resp> implements | ||
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, | ||
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>, | ||
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>, | ||
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> { | ||
private final AnotherReflectableServiceImplBase serviceImpl; | ||
private final int methodId; | ||
|
||
MethodHandlers(AnotherReflectableServiceImplBase serviceImpl, int methodId) { | ||
this.serviceImpl = serviceImpl; | ||
this.methodId = methodId; | ||
} | ||
|
||
@java.lang.Override | ||
@java.lang.SuppressWarnings("unchecked") | ||
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) { | ||
switch (methodId) { | ||
case METHODID_METHOD: | ||
serviceImpl.method((io.grpc.reflection.testing.Request) request, | ||
(io.grpc.stub.StreamObserver<io.grpc.reflection.testing.Reply>) responseObserver); | ||
break; | ||
default: | ||
throw new AssertionError(); | ||
} | ||
} | ||
|
||
@java.lang.Override | ||
@java.lang.SuppressWarnings("unchecked") | ||
public io.grpc.stub.StreamObserver<Req> invoke( | ||
io.grpc.stub.StreamObserver<Resp> responseObserver) { | ||
switch (methodId) { | ||
default: | ||
throw new AssertionError(); | ||
} | ||
} | ||
} | ||
|
||
private static abstract class AnotherReflectableServiceBaseDescriptorSupplier | ||
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { | ||
AnotherReflectableServiceBaseDescriptorSupplier() {} | ||
|
||
@java.lang.Override | ||
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { | ||
return io.grpc.reflection.testing.ReflectionTestProto.getDescriptor(); | ||
} | ||
|
||
@java.lang.Override | ||
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { | ||
return getFileDescriptor().findServiceByName("AnotherReflectableService"); | ||
} | ||
} | ||
|
||
private static final class AnotherReflectableServiceFileDescriptorSupplier | ||
extends AnotherReflectableServiceBaseDescriptorSupplier { | ||
AnotherReflectableServiceFileDescriptorSupplier() {} | ||
} | ||
|
||
private static final class AnotherReflectableServiceMethodDescriptorSupplier | ||
extends AnotherReflectableServiceBaseDescriptorSupplier | ||
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { | ||
private final String methodName; | ||
|
||
AnotherReflectableServiceMethodDescriptorSupplier(String methodName) { | ||
this.methodName = methodName; | ||
} | ||
|
||
@java.lang.Override | ||
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { | ||
return getServiceDescriptor().findMethodByName(methodName); | ||
} | ||
} | ||
|
||
private static volatile io.grpc.ServiceDescriptor serviceDescriptor; | ||
|
||
public static io.grpc.ServiceDescriptor getServiceDescriptor() { | ||
io.grpc.ServiceDescriptor result = serviceDescriptor; | ||
if (result == null) { | ||
synchronized (AnotherReflectableServiceGrpc.class) { | ||
result = serviceDescriptor; | ||
if (result == null) { | ||
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) | ||
.setSchemaDescriptor(new AnotherReflectableServiceFileDescriptorSupplier()) | ||
.addMethod(getMethodMethod()) | ||
.build(); | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
protected
leaks it. Using package-private is probably better.