@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") public static io.grpc.MethodDescriptor<com.example.grpc.HelloRequest, com.example.grpc.HelloResponse> getGreetingMethod() { return getGreetingMethodHelper(); }
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) .addMethod( getGreetingMethodHelper(), asyncUnaryCall( new MethodHandlers< com.example.grpc.HelloRequest, com.example.grpc.HelloResponse>( this, METHODID_GREETING))) .build(); } }
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") public static io.grpc.MethodDescriptor<com.example.grpc.HelloRequest, com.example.grpc.HelloResponse> getSecondGreetingMethod() { return getSecondGreetingMethodHelper(); }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { io.grpc.ServiceDescriptor result = serviceDescriptor; if (result == null) { synchronized (GreetingServiceGrpc.class) { result = serviceDescriptor; if (result == null) { serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) .setSchemaDescriptor(new GreetingServiceFileDescriptorSupplier()) .addMethod(getGreetingMethodHelper()) .addMethod(getSecondGreetingMethodHelper()) .build(); } } } return result; } }
public static void main(String[] args) throws InterruptedException { ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 8080) .usePlaintext(true) .build(); GreetingServiceGrpc.GreetingServiceBlockingStub stub = GreetingServiceGrpc.newBlockingStub(channel); HelloResponse helloResponse = stub.greeting( HelloRequest.newBuilder() .setName("Ray") .setAge(18) .setSentiment(Sentiment.HAPPY) .build()); System.out.println(helloResponse); channel.shutdown(); } }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { io.grpc.ServiceDescriptor result = serviceDescriptor; if (result == null) { synchronized (GreetingServiceGrpc.class) { result = serviceDescriptor; if (result == null) { serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) .setSchemaDescriptor(new GreetingServiceFileDescriptorSupplier()) .addMethod(getGreetingMethodHelper()) .addMethod(getSecondGreetingMethodHelper()) .build(); } } } return result; } }
static public void main(String[] args) throws IOException, InterruptedException { JwtServerInterceptor jwtInterceptor = new JwtServerInterceptor(Constant.JWT_SECRET); ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 8080) .usePlaintext(true) .intercept(new JwtClientInterceptor()) .intercept(new TraceIdClientInterceptor()) .build(); GreetingServiceGrpc.GreetingServiceBlockingStub greetingStub = GreetingServiceGrpc.newBlockingStub(channel); Server goodbyeServer = ServerBuilder.forPort(9090) .addService(ServerInterceptors.intercept(new GoodbyeServiceImpl(greetingStub), jwtInterceptor, new TraceIdServerInterceptor())) .build(); goodbyeServer.start(); System.out.println("Server started!"); goodbyeServer.awaitTermination(); }
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") public static io.grpc.MethodDescriptor<com.example.grpc.HelloRequest, com.example.grpc.HelloResponse> getGreetingMethod() { return getGreetingMethodHelper(); }
static public void main(String[] args) throws IOException, InterruptedException { Brave brave = Constant.brave("goodbye-service"); ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 8080) .usePlaintext(true) .intercept(new BraveGrpcClientInterceptor(brave)) .build(); GreetingServiceGrpc.GreetingServiceBlockingStub greetingStub = GreetingServiceGrpc.newBlockingStub(channel); Server goodbyeServer = ServerBuilder.forPort(9090) .addService(ServerInterceptors.intercept(new GoodbyeServiceImpl(greetingStub), new BraveGrpcServerInterceptor(brave), MonitoringServerInterceptor.create(Configuration.allMetrics()))) .build(); goodbyeServer.start(); PrometheusServer prometheusServer = new PrometheusServer(CollectorRegistry.defaultRegistry, 8081); prometheusServer.start(); System.out.println("Server started!"); goodbyeServer.awaitTermination(); prometheusServer.shutdown(); }
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) .addMethod( getGreetingMethodHelper(), asyncUnaryCall( new MethodHandlers< com.example.grpc.HelloRequest, com.example.grpc.HelloResponse>( this, METHODID_GREETING))) .addMethod( getSecondGreetingMethodHelper(), asyncUnaryCall( new MethodHandlers< com.example.grpc.HelloRequest, com.example.grpc.HelloResponse>( this, METHODID_SECOND_GREETING))) .build(); } }
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") public static io.grpc.MethodDescriptor<com.example.grpc.HelloRequest, com.example.grpc.HelloResponse> getSecondGreetingMethod() { return getSecondGreetingMethodHelper(); }
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") public static io.grpc.MethodDescriptor<com.example.grpc.HelloRequest, com.example.grpc.HelloResponse> getGreetingMethod() { return getGreetingMethodHelper(); }
public static void main(String[] args) { String jwt = createJwt(Constant.JWT_SECRET, "authClient", "rayt"); //String jwt = createJwt("123124123", "authClient", "rayt"); System.out.println("Created a JWT: " + jwt); JwtCallCredential callCredential = new JwtCallCredential(jwt); ManagedChannel greetingChannel = ManagedChannelBuilder.forAddress("localhost", 8080) .usePlaintext(true) .intercept(new TraceIdClientInterceptor()) .build(); ManagedChannel goodbyeChannel = ManagedChannelBuilder.forAddress("localhost", 9090) .usePlaintext(true) .intercept(new TraceIdClientInterceptor()) .build(); Context.current().withValue(Constant.TRACE_ID_CTX_KEY, "1").run(() -> { GreetingServiceGrpc.GreetingServiceBlockingStub greetingStub = GreetingServiceGrpc.newBlockingStub(greetingChannel).withCallCredentials(callCredential); HelloResponse helloResponse = greetingStub.greeting(HelloRequest.newBuilder().setName("Ray").build()); System.out.println(helloResponse); }); Context.current().withValue(Constant.TRACE_ID_CTX_KEY, "2").run(() -> { GoodbyeServiceGrpc.GoodbyeServiceBlockingStub goodbyeStub = GoodbyeServiceGrpc.newBlockingStub(goodbyeChannel).withCallCredentials(callCredential); GoodbyeResponse goodbyeResponse = goodbyeStub.goodbye(GoodbyeRequest.newBuilder().setName("Jason").build()); System.out.println(goodbyeResponse); }); }
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) .addMethod( getGreetingMethodHelper(), asyncUnaryCall( new MethodHandlers< com.example.grpc.HelloRequest, com.example.grpc.HelloResponse>( this, METHODID_GREETING))) .addMethod( getSecondGreetingMethodHelper(), asyncUnaryCall( new MethodHandlers< com.example.grpc.HelloRequest, com.example.grpc.HelloResponse>( this, METHODID_SECOND_GREETING))) .build(); } }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { io.grpc.ServiceDescriptor result = serviceDescriptor; if (result == null) { synchronized (GreetingServiceGrpc.class) { result = serviceDescriptor; if (result == null) { serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) .setSchemaDescriptor(new GreetingServiceFileDescriptorSupplier()) .addMethod(getGreetingMethodHelper()) .build(); } } } return result; } }