io.grpc.reflection.v1alpha.ExtensionNumberResponse Java Examples
The following examples show how to use
io.grpc.reflection.v1alpha.ExtensionNumberResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProtoReflectionService.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
private void getAllExtensions(ServerReflectionRequest request) { String type = request.getAllExtensionNumbersOfType(); Set<Integer> extensions = serverReflectionIndex.getExtensionNumbersOfType(type); if (extensions != null) { ExtensionNumberResponse.Builder builder = ExtensionNumberResponse.newBuilder() .setBaseTypeName(type) .addAllExtensionNumber(extensions); serverCallStreamObserver.onNext( ServerReflectionResponse.newBuilder() .setValidHost(request.getHost()) .setOriginalRequest(request) .setAllExtensionNumbersResponse(builder) .build()); } else { sendErrorResponse(request, Status.Code.NOT_FOUND, "Type not found."); } }
Example #2
Source File: ReflectionService.java From quarkus with Apache License 2.0 | 6 votes |
private ServerReflectionResponse getAllExtensions(ServerReflectionRequest request) { String type = request.getAllExtensionNumbersOfType(); Set<Integer> extensions = index.getExtensionNumbersOfType(type); if (extensions != null) { ExtensionNumberResponse.Builder builder = ExtensionNumberResponse.newBuilder() .setBaseTypeName(type) .addAllExtensionNumber(extensions); return ServerReflectionResponse.newBuilder() .setValidHost(request.getHost()) .setOriginalRequest(request) .setAllExtensionNumbersResponse(builder) .build(); } else { return getErrorResponse(request, Status.Code.NOT_FOUND, "Type not found."); } }
Example #3
Source File: ProtoReflectionService.java From grpc-java with Apache License 2.0 | 6 votes |
private void getAllExtensions(ServerReflectionRequest request) { String type = request.getAllExtensionNumbersOfType(); Set<Integer> extensions = serverReflectionIndex.getExtensionNumbersOfType(type); if (extensions != null) { ExtensionNumberResponse.Builder builder = ExtensionNumberResponse.newBuilder() .setBaseTypeName(type) .addAllExtensionNumber(extensions); serverCallStreamObserver.onNext( ServerReflectionResponse.newBuilder() .setValidHost(request.getHost()) .setOriginalRequest(request) .setAllExtensionNumbersResponse(builder) .build()); } else { sendErrorResponse(request, Status.Code.NOT_FOUND, "Type not found."); } }
Example #4
Source File: ProtoReflectionServiceTest.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@Test public void allExtensionNumbersOfTypeForMutableServices() throws Exception { String type = "grpc.reflection.testing.TypeWithExtensions"; ServerReflectionRequest request = ServerReflectionRequest.newBuilder() .setHost(TEST_HOST) .setAllExtensionNumbersOfType(type) .build(); ServerReflectionResponse goldenResponse = ServerReflectionResponse.newBuilder() .setValidHost(TEST_HOST) .setOriginalRequest(request) .setAllExtensionNumbersResponse( ExtensionNumberResponse.newBuilder() .setBaseTypeName(type) .addExtensionNumber(200) .build()) .build(); StreamRecorder<ServerReflectionResponse> responseObserver = StreamRecorder.create(); StreamObserver<ServerReflectionRequest> requestObserver = stub.serverReflectionInfo(responseObserver); handlerRegistry.addService(dynamicService); requestObserver.onNext(request); requestObserver.onCompleted(); StreamRecorder<ServerReflectionResponse> responseObserver2 = StreamRecorder.create(); StreamObserver<ServerReflectionRequest> requestObserver2 = stub.serverReflectionInfo(responseObserver2); handlerRegistry.removeService(dynamicService); requestObserver2.onNext(request); requestObserver2.onCompleted(); StreamRecorder<ServerReflectionResponse> responseObserver3 = StreamRecorder.create(); StreamObserver<ServerReflectionRequest> requestObserver3 = stub.serverReflectionInfo(responseObserver3); requestObserver3.onNext(request); requestObserver3.onCompleted(); assertEquals( ServerReflectionResponse.MessageResponseCase.ERROR_RESPONSE, responseObserver.firstValue().get().getMessageResponseCase()); assertEquals(goldenResponse, responseObserver2.firstValue().get()); assertEquals( ServerReflectionResponse.MessageResponseCase.ERROR_RESPONSE, responseObserver3.firstValue().get().getMessageResponseCase()); }
Example #5
Source File: ProtoReflectionServiceTest.java From grpc-java with Apache License 2.0 | 4 votes |
@Test public void allExtensionNumbersOfTypeForMutableServices() throws Exception { String type = "grpc.reflection.testing.TypeWithExtensions"; ServerReflectionRequest request = ServerReflectionRequest.newBuilder() .setHost(TEST_HOST) .setAllExtensionNumbersOfType(type) .build(); ServerReflectionResponse goldenResponse = ServerReflectionResponse.newBuilder() .setValidHost(TEST_HOST) .setOriginalRequest(request) .setAllExtensionNumbersResponse( ExtensionNumberResponse.newBuilder() .setBaseTypeName(type) .addExtensionNumber(200) .build()) .build(); StreamRecorder<ServerReflectionResponse> responseObserver = StreamRecorder.create(); StreamObserver<ServerReflectionRequest> requestObserver = stub.serverReflectionInfo(responseObserver); handlerRegistry.addService(dynamicService); requestObserver.onNext(request); requestObserver.onCompleted(); StreamRecorder<ServerReflectionResponse> responseObserver2 = StreamRecorder.create(); StreamObserver<ServerReflectionRequest> requestObserver2 = stub.serverReflectionInfo(responseObserver2); handlerRegistry.removeService(dynamicService); requestObserver2.onNext(request); requestObserver2.onCompleted(); StreamRecorder<ServerReflectionResponse> responseObserver3 = StreamRecorder.create(); StreamObserver<ServerReflectionRequest> requestObserver3 = stub.serverReflectionInfo(responseObserver3); requestObserver3.onNext(request); requestObserver3.onCompleted(); assertEquals( ServerReflectionResponse.MessageResponseCase.ERROR_RESPONSE, responseObserver.firstValue().get().getMessageResponseCase()); assertEquals(goldenResponse, responseObserver2.firstValue().get()); assertEquals( ServerReflectionResponse.MessageResponseCase.ERROR_RESPONSE, responseObserver3.firstValue().get().getMessageResponseCase()); }