Skip to content
Permalink
Browse files
define extension fun return value
  • Loading branch information
DLive committed Jul 24, 2019
1 parent af4b990 commit 9d8eac67bc3f4eab5b2042f2802410aa0b7059ee
Showing 7 changed files with 13 additions and 20 deletions.
@@ -89,8 +89,8 @@ run_fold1([M | Rest], HookName, Fun, Args0, Acc) ->
Acc;
{stop, NewAcc} ->
NewAcc;
_ ->
run_fold1(Rest, HookName, Fun, Args0, Ret)
{ok,NewAcc2} ->
run_fold1(Rest, HookName, Fun, Args0, NewAcc2)
end.

invoke_foldr(HookName, Fun, Args, Acc) ->
@@ -116,8 +116,6 @@ do_invoke([M | Rest], HookName, Fun, Args0, Acc) ->
{'EXIT', Reason} ->
logger:error("~p~n error running hook: ~p~n", [HookName, Reason]),
do_invoke(Rest, HookName, Fun, Args0, Acc);
stop ->
Acc;
{stop, NewAcc} ->
NewAcc;
{ok, Args2, NewAcc2} ->
@@ -17,12 +17,11 @@
-module(dubbo_filter).
-include("dubbo.hrl").

-type filter_result() :: {stop, term()}|{error, term()}|term().
-type filter_result() :: {ok, Invocation :: invocation(), Acc :: invoke_result()}|{stop, term()}.

-callback(invoke(Invocation :: #dubbo_rpc_invocation{}, Acc :: invoke_result()) -> filter_result()).

-callback(on_response(Invocation :: invocation(), Result :: invoke_result()) -> filter_result()).
%% API
-export([]).



@@ -18,6 +18,6 @@

-include("dubbo.hrl").

-callback refer(Url :: binary(), Acc :: term()) -> ok.
-callback refer(Url :: binary(), Acc :: term()) -> {ok,Acc}.

-callback export(Invoker :: #invoker{}, Acc :: term()) -> ok.
-callback export(Invoker :: #invoker{}, Acc :: term()) -> {ok,Acc}.
@@ -15,6 +15,7 @@
%% limitations under the License.
%%------------------------------------------------------------------------------
-module(dubbo_protocol_dubbo).
-behaviour(dubbo_protocol).

-include("dubboerl.hrl").
-include("dubbo.hrl").
@@ -30,7 +31,7 @@ refer(Url, Acc) ->
{ok, Invoker} = do_refer(UrlInfo),
{ok, Invoker};
_ ->
{skip, Acc}
{ok, Acc}
end.

do_refer(UrlInfo) ->
@@ -34,8 +34,7 @@ refer(Url, Acc) ->
dubbo_registry:register(RegistryName, ConsumerUrl),

dubbo_directory:subscribe(RegistryName, ConsumerUrl),

ok.
{ok,Acc}.

export(Invoker, Acc) ->
{ok, UrlInfo} = dubbo_common_fun:parse_url(Invoker#invoker.url),
@@ -48,15 +47,13 @@ export(Invoker, Acc) ->
dubbo_registry:register(RegistryName, ProtocolUrl),

register_export_info(ProtocolUrl, RegistryName, InterfaceKey),
{ok, Invoker}.
{ok, Acc}.

destroy() ->
List = ets:tab2list(?SERVICE_EXPORT_TABLE),
lists:map(
fun(Item) ->

{ProtocolUrl, RegistryModule, _} = Item,
io:format(user, "destroy url ~p~n", [ProtocolUrl]),
unexport(RegistryModule, ProtocolUrl)
end, List),
ok.
@@ -17,9 +17,9 @@
-module(dubbo_registry).
-include("dubboerl.hrl").

-callback start(Url :: binary) -> ok.
-callback register(Url :: binary()) -> term().
-callback subscribe(SubcribeUrl :: binary(), NotifyFun :: function()) -> ok.
-callback start(Url :: binary) -> ok | {error,Reason::term()}.
-callback register(Url :: binary()) -> ok | {error,Reason::term()}.
-callback subscribe(SubcribeUrl :: binary(), NotifyFun :: function()) -> ok | {error,Reason::term()}.

%% API
-export([setup_register/1, register/2, unregister/2, get_registry_host_port/0, get_registry_type/0, get_registry_module/1]).
@@ -39,8 +39,6 @@ do_export_protocol(ProviderInfo) ->
ok.




get_registry_url(ProviderInfo) ->
{Host, Port} = dubbo_registry:get_registry_host_port(),
UrlInfo = #dubbo_url{

0 comments on commit 9d8eac6

Please sign in to comment.