This is an automated email from the ASF dual-hosted git repository. dlive pushed a commit to branch 0.4.0 in repository https://gitbox.apache.org/repos/asf/dubbo-erlang.git
commit 051bb2a1f46cd55f221f2e4ce79c0517a98e5a0f Author: DLive <[email protected]> AuthorDate: Tue Jun 11 23:21:37 2019 +0800 redesign the subscription process --- src/dubbo_directory.erl | 27 ++++++++++++++++++++++++--- src/dubbo_protocol.erl | 2 +- src/dubbo_protocol_dubbo.erl | 6 +++++- src/dubbo_protocol_registry.erl | 4 ++-- src/dubbo_reference_config.erl | 2 +- src/dubbo_registry_zookeeper.erl | 2 +- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/dubbo_directory.erl b/src/dubbo_directory.erl index 2356e7c..08e959c 100644 --- a/src/dubbo_directory.erl +++ b/src/dubbo_directory.erl @@ -18,7 +18,7 @@ -behaviour(gen_server). --export([subscribe/2,notify/1]). +-export([subscribe/2,notify/2]). %% API -export([start_link/0]). @@ -80,10 +80,31 @@ subscribe(RegistryName,SubcribeUrl)-> {error,Reason} end. -notify(UrlList)-> - dubbo_consumer_pool:start_consumer(Interface, UrlList), +notify(Interface,UrlList)-> + %% @todo if UrlList size is 1, and protocol is empty ,need destroyAllInvokers + + case dubbo_extension:run_fold(protocol,refer,[UrlList],{error,no_protocol}) of + {ok,Invokers} -> + ok; + {error,no_protocol}-> + error + end, +%% dubbo_consumer_pool:start_consumer(Interface, UrlList), ok. +refresh_invoker(UrlList)-> + NewInvokers = refresh_invoker(UrlList,[]). + +refresh_invoker([Url|Rest],Acc)-> + case dubbo_extension:run_fold(protocol,refer,[Url],undefined) of + undefined -> + refresh_invoker(Rest,Acc); + {ok,Invoker} -> + refresh_invoker(Rest,[Invoker|Acc]); + {stop,_}-> + refresh_invoker(Rest,Acc) + end. + %%-------------------------------------------------------------------- %% @private %% @doc diff --git a/src/dubbo_protocol.erl b/src/dubbo_protocol.erl index 3c82119..8808fc8 100644 --- a/src/dubbo_protocol.erl +++ b/src/dubbo_protocol.erl @@ -16,7 +16,7 @@ %%------------------------------------------------------------------------------ -module(dubbo_protocol). --callback refer(InterfaceClassInfo,Url)->ok. +-callback refer(Url)->ok. %% API -export([refer/2]). diff --git a/src/dubbo_protocol_dubbo.erl b/src/dubbo_protocol_dubbo.erl index 2242939..c2fb6dd 100644 --- a/src/dubbo_protocol_dubbo.erl +++ b/src/dubbo_protocol_dubbo.erl @@ -18,4 +18,8 @@ -author("dlive"). %% API --export([]). +-export([refer/1]). + +refer(Url)-> + + {ok,todo}. \ No newline at end of file diff --git a/src/dubbo_protocol_registry.erl b/src/dubbo_protocol_registry.erl index f1d9bc4..8277c7e 100644 --- a/src/dubbo_protocol_registry.erl +++ b/src/dubbo_protocol_registry.erl @@ -20,9 +20,9 @@ -include("dubboerl.hrl"). %% API --export([]). +-export([refer/1]). -refer(InterfaceClassInfo,Url)-> +refer(Url)-> {ok,UrlInfo} = dubbo_common_fun:parse_url(Url), {ok,RegistryName} = dubbo_registry:setup_register(UrlInfo), diff --git a/src/dubbo_reference_config.erl b/src/dubbo_reference_config.erl index f6e8bdd..6c58a50 100644 --- a/src/dubbo_reference_config.erl +++ b/src/dubbo_reference_config.erl @@ -35,7 +35,7 @@ create_proxy(InitConfigMap)-> InterfaceClassInfo = #{}, Para = gen_parameter(), Url = gen_registry_url(Para), - dubbo_extension:run(protoco_wapper,refer,[InterfaceClassInfo,Url]), + dubbo_extension:run(protocol_wapper,refer,[Url]), ok. %%application=hello-world&dubbo=2.0.2&pid=68901&refer=application=hello-world&default.check=false&default.lazy=false&default.retries=0&default.sticky=false&default.timeout=300000&dubbo=2.0.2&interface=org.apache.dubbo.erlang.sample.service.facade.UserOperator&lazy=false&methods=queryUserInfo,queryUserList,genUserId,getUserInfo&pid=68901®ister.ip=127.0.0.1&release=2.7.1&retries=0&side=consumer&sticky=false×tamp=1559727789953®istry=zookeeper&release=2.7.1×tamp=1559727842451 diff --git a/src/dubbo_registry_zookeeper.erl b/src/dubbo_registry_zookeeper.erl index ea9ef62..0b5b3f5 100644 --- a/src/dubbo_registry_zookeeper.erl +++ b/src/dubbo_registry_zookeeper.erl @@ -240,7 +240,7 @@ register_provider_path(Provider, State) -> get_provider_list(InterfaceName,ZkPid,NotifyFun) -> InterfacePath = <<<<"/dubbo/">>/binary, InterfaceName/binary, <<"/providers">>/binary>>, ChildList= get_provider_and_start(ZkPid, InterfaceName, InterfacePath), - NotifyFun(ChildList), + NotifyFun(InterfaceName,ChildList), ok. get_provider_and_start(Pid, Interface, Path) -> case erlzk:get_children(Pid, Path, spawn(dubbo_registry_zookeeper, provider_watcher, [Interface])) of
