Skip to content
Permalink
Browse files
redesign the subscription process
  • Loading branch information
DLive committed Jun 11, 2019
1 parent 07e743a commit 051bb2a1f46cd55f221f2e4ce79c0517a98e5a0f
Showing 6 changed files with 34 additions and 9 deletions.
@@ -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
@@ -16,7 +16,7 @@
%%------------------------------------------------------------------------------
-module(dubbo_protocol).

-callback refer(InterfaceClassInfo,Url)->ok.
-callback refer(Url)->ok.

%% API
-export([refer/2]).
@@ -18,4 +18,8 @@
-author("dlive").

%% API
-export([]).
-export([refer/1]).

refer(Url)->

{ok,todo}.
@@ -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),
@@ -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&register.ip=127.0.0.1&release=2.7.1&retries=0&side=consumer&sticky=false&timestamp=1559727789953&registry=zookeeper&release=2.7.1&timestamp=1559727842451
@@ -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

0 comments on commit 051bb2a

Please sign in to comment.