Skip to content

Commit 533e3ca

Browse files
committed
Fix to use the correct gRPC method type when creating a method descriptor
1 parent 4c91fda commit 533e3ca

File tree

1 file changed

+16
-1
lines changed
  • nima/grpc/webserver/src/main/java/io/helidon/nima/grpc/webserver

1 file changed

+16
-1
lines changed

nima/grpc/webserver/src/main/java/io/helidon/nima/grpc/webserver/Grpc.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private static <ResT, ReqT> Grpc<ReqT, ResT> grpc(Descriptors.FileDescriptor pro
125125

126126
io.grpc.MethodDescriptor.Builder<ReqT, ResT> grpcDesc = io.grpc.MethodDescriptor.<ReqT, ResT>newBuilder()
127127
.setFullMethodName(io.grpc.MethodDescriptor.generateFullMethodName(serviceName, methodName))
128-
.setType(io.grpc.MethodDescriptor.MethodType.UNARY).setFullMethodName(path).setRequestMarshaller(reqMarshaller)
128+
.setType(getMethodType(mtd)).setFullMethodName(path).setRequestMarshaller(reqMarshaller)
129129
.setResponseMarshaller(resMarshaller).setSampledToLocalTracing(true);
130130

131131
return new Grpc<>(grpcDesc.build(), PathMatchers.exact(path), requestType, responsetype, callHandler);
@@ -178,4 +178,19 @@ private static String getOuterClassFromFileName(String name) {
178178

179179
return sb.toString();
180180
}
181+
182+
private static io.grpc.MethodDescriptor.MethodType getMethodType(Descriptors.MethodDescriptor mtd) {
183+
if (mtd.isClientStreaming()) {
184+
if (mtd.isServerStreaming()) {
185+
return MethodDescriptor.MethodType.BIDI_STREAMING;
186+
}
187+
else {
188+
return MethodDescriptor.MethodType.CLIENT_STREAMING;
189+
}
190+
}
191+
else if (mtd.isServerStreaming()) {
192+
return MethodDescriptor.MethodType.SERVER_STREAMING;
193+
}
194+
return MethodDescriptor.MethodType.UNARY;
195+
}
181196
}

0 commit comments

Comments
 (0)