diff options
author | Carl Mastrangelo <notcarl@google.com> | 2017-10-30 10:30:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-30 10:30:34 -0700 |
commit | 30b59885b7496b53eb17f64ba1d822c2d9a6c69a (patch) | |
tree | eab8390b6f1568020e811be297ee5f85cb5e900e /grpclb | |
parent | 53c135a48f979e236678af40aa88909f6564ec97 (diff) | |
download | grpc-grpc-java-30b59885b7496b53eb17f64ba1d822c2d9a6c69a.tar.gz |
compiler: add methods for accessing method descriptors
* MethodDescriptor is lazy loaded, so protobuf loading only happens on demand. This also means tracing registration happens on demand.
* The names of the getters all being with `method`. This makes it harder for autocomplete to pick them up.
* A new field is used, which matches the getter name. Rather than make the new-getters reference the old-fields, make the old-fields reference the new getters. This makes removal of the old-fields a simple operation.
* The getters may not be inlineable, but thats an easy fix if it ends up being a problem. Not worth premature optimization (but is worth future work).
The expected timeline for this is adding this to the 1.8 cut, and deprecating the old-fields. They will be removed in 1.9.
Diffstat (limited to 'grpclb')
-rw-r--r-- | grpclb/src/generated/main/grpc/io/grpc/grpclb/LoadBalancerGrpc.java | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/grpclb/src/generated/main/grpc/io/grpc/grpclb/LoadBalancerGrpc.java b/grpclb/src/generated/main/grpc/io/grpc/grpclb/LoadBalancerGrpc.java index 9ee54dfea..23cfda032 100644 --- a/grpclb/src/generated/main/grpc/io/grpc/grpclb/LoadBalancerGrpc.java +++ b/grpclb/src/generated/main/grpc/io/grpc/grpclb/LoadBalancerGrpc.java @@ -28,19 +28,37 @@ public final class LoadBalancerGrpc { // Static method descriptors that strictly reflect the proto. @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link getBalanceLoadMethod()} instead. public static final io.grpc.MethodDescriptor<io.grpc.grpclb.LoadBalanceRequest, - io.grpc.grpclb.LoadBalanceResponse> METHOD_BALANCE_LOAD = - io.grpc.MethodDescriptor.<io.grpc.grpclb.LoadBalanceRequest, io.grpc.grpclb.LoadBalanceResponse>newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) - .setFullMethodName(generateFullMethodName( - "grpc.lb.v1.LoadBalancer", "BalanceLoad")) - .setRegisterForTracing(true) - .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - io.grpc.grpclb.LoadBalanceRequest.getDefaultInstance())) - .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - io.grpc.grpclb.LoadBalanceResponse.getDefaultInstance())) - .setSchemaDescriptor(new LoadBalancerMethodDescriptorSupplier("BalanceLoad")) - .build(); + io.grpc.grpclb.LoadBalanceResponse> METHOD_BALANCE_LOAD = getBalanceLoadMethod(); + + private static volatile io.grpc.MethodDescriptor<io.grpc.grpclb.LoadBalanceRequest, + io.grpc.grpclb.LoadBalanceResponse> getBalanceLoadMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor<io.grpc.grpclb.LoadBalanceRequest, + io.grpc.grpclb.LoadBalanceResponse> getBalanceLoadMethod() { + io.grpc.MethodDescriptor<io.grpc.grpclb.LoadBalanceRequest, io.grpc.grpclb.LoadBalanceResponse> getBalanceLoadMethod; + if ((getBalanceLoadMethod = LoadBalancerGrpc.getBalanceLoadMethod) == null) { + synchronized (LoadBalancerGrpc.class) { + if ((getBalanceLoadMethod = LoadBalancerGrpc.getBalanceLoadMethod) == null) { + LoadBalancerGrpc.getBalanceLoadMethod = getBalanceLoadMethod = + io.grpc.MethodDescriptor.<io.grpc.grpclb.LoadBalanceRequest, io.grpc.grpclb.LoadBalanceResponse>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) + .setFullMethodName(generateFullMethodName( + "grpc.lb.v1.LoadBalancer", "BalanceLoad")) + .setRegisterForTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.grpc.grpclb.LoadBalanceRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.grpc.grpclb.LoadBalanceResponse.getDefaultInstance())) + .setSchemaDescriptor(new LoadBalancerMethodDescriptorSupplier("BalanceLoad")) + .build(); + } + } + } + return getBalanceLoadMethod; + } /** * Creates a new async stub that supports all call types for the service @@ -76,7 +94,7 @@ public final class LoadBalancerGrpc { */ public io.grpc.stub.StreamObserver<io.grpc.grpclb.LoadBalanceRequest> balanceLoad( io.grpc.stub.StreamObserver<io.grpc.grpclb.LoadBalanceResponse> responseObserver) { - return asyncUnimplementedStreamingCall(METHOD_BALANCE_LOAD, responseObserver); + return asyncUnimplementedStreamingCall(getBalanceLoadMethod(), responseObserver); } @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { @@ -118,7 +136,7 @@ public final class LoadBalancerGrpc { public io.grpc.stub.StreamObserver<io.grpc.grpclb.LoadBalanceRequest> balanceLoad( io.grpc.stub.StreamObserver<io.grpc.grpclb.LoadBalanceResponse> responseObserver) { return asyncBidiStreamingCall( - getChannel().newCall(METHOD_BALANCE_LOAD, getCallOptions()), responseObserver); + getChannel().newCall(getBalanceLoadMethod(), getCallOptions()), responseObserver); } } |