另外,测过性能没有?我看核心链路上直接走反射,比如: ```java /** * 这里返回的impl必须要有所有的方法, Stub BlockingStube FutureStub */ @Override protected <T> T doRefer(Class<T> type, URL url) throws RpcException { //通过 type(IGreeter),反射获得外部类(GreeterGrpc),调用静态方法(getDubboStub()),获得并返回(T)stub Class<?> enclosingClass = type.getEnclosingClass(); if (enclosingClass == null) { throw new IllegalArgumentException( type.getName() + " must be declared inside protobuf generated classes, " + "should be something like ServiceNameGrpc.IServiceName."); }
final Method dubboStubMethod; try { dubboStubMethod = enclosingClass.getDeclaredMethod("getDubboStub", Channel.class, long.class); } catch (NoSuchMethodException e) { throw new IllegalArgumentException("Does not find getDubboStub in " + enclosingClass.getName() + ", please use the customized protoc-gen-grpc-dubbo-java to update the generated classes."); } Channel channel = channelMap.computeIfAbsent(url.getServiceKey(), k -> ManagedChannelBuilder.forAddress(url.getHost(), url.getPort()).usePlaintext().build() ); try { int timeout = url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT); @SuppressWarnings("unchecked") final T stub = (T) dubboStubMethod.invoke(null, channel, timeout); return stub; } catch (IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException("Could not create stub through reflection.", e); } } ``` 可以参考 [motan的GRPC实现](https://github.com/weibocom/motan/blob/master/motan-extension/protocol-extension/motan-protocol-grpc/src/main/java/com/weibo/api/motan/protocol/grpc/GrpcProtocol.java) [ Full content available at: https://github.com/apache/dubbo/issues/3999 ] This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
--------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org