Skip to content

Commit

Permalink
grpc protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj committed Sep 6, 2019
1 parent 0946357 commit 50f8a51
Showing 1 changed file with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,7 @@ public class GrpcProtocol extends AbstractProxyProtocol {

private final Map<String, ManagedChannel> channelMap = new ConcurrentHashMap<>();

/**
* 传进来的impl implements DubboInterface, DubboInterface包含特定的3个通用方法就可以了
* @param impl
* @param type
* @param url
* @param <T>
* @return
* @throws RpcException
*/

@Override
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
String key = url.getAddress();
Expand All @@ -86,14 +78,6 @@ public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
return super.export(new GrpcInvoker<>(invoker));
}

/**
* 这里返回的impl必须要有所有的方法, Stub BlockingStube FutureStub
* @param type
* @param url
* @param <T>
* @return
* @throws RpcException
*/
@Override
protected <T> T doRefer(Class<T> type, URL url) throws RpcException {
Class<?> enclosingClass = type.getEnclosingClass();
Expand Down Expand Up @@ -130,7 +114,8 @@ public int getDefaultPort() {

@Override
public void destroy() {
// FIXME
serverMap.values().forEach(GrpcServer::stop);
channelMap.values().forEach(ManagedChannel::shutdown);
}

private class GrpcServer {
Expand All @@ -154,6 +139,10 @@ public Server getServer() {
public DubboHandlerRegistry getRegistry() {
return registry;
}

public void stop() {
this.server.shutdown();
}
}

private class GrpcInvoker<T> implements Invoker<T> {
Expand Down

0 comments on commit 50f8a51

Please sign in to comment.