Skip to content
Permalink
Browse files
feature: support protocol extension
  • Loading branch information
DLive committed Jul 23, 2019
1 parent 91faffc commit af4b9904242b34fa2fb15e4b767613272ff2a887
Showing 46 changed files with 1,264 additions and 1,222 deletions.
@@ -20,11 +20,10 @@
{registry,zookeeper},
{zookeeper_list,[{"127.0.0.1",2181}]},
{application,<<"testdubboerl">>},
{registry,true},
{protocol,hessian},
{port,20881},
{serialization,hessian},
{protocol, {dubbo, [{port, 20882}]}},
{consumer,[
% {<<"org.apache.dubbo.erlang.sample.service.facade.UserOperator">>,[]}
%% {<<"org.apache.dubbo.erlang.sample.service.facade.UserOperator">>,[]}
]},
{provider,[
{dubbo_service_user_impl,userOperator,<<"org.apache.dubbo.erlang.sample.service.facade.UserOperator">>,[]}
@@ -14,7 +14,10 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%------------------------------------------------------------------------------
-module(dubbo_common).

%% API
-export([]).

-define(CATEGORY_KEY, <<"category">>).

-define(PROVIDERS_CATEGORY, <<"providers">>).

-define(CONSUMERS_CATEGORY, <<"consumers">>).
@@ -63,15 +63,37 @@
decode_state
}).


-record(reference_config,{
interface,
application = <<"NoName">> :: binary(),
category = <<"consumers">> :: binary(),
check = false :: boolean(),
default_timeout = 500 :: integer(),
dubbo_version = <<"2.5.3">> :: binary(),
methods = [] :: list(),
revision = <<"">> :: binary(),
side = <<"consumers">> :: binary(),
sync = false ::boolean()

}).

-record(dubbo_rpc_invocation, {
serialVersionUID = -4355285085441097045,
className :: string(),
classVersion :: string(),
methodName :: string(),
parameterDesc :: string(),
className :: binary(),
classVersion :: binary(),
methodName :: binary(),
parameterDesc :: binary(),
parameterTypes = [] :: [#type_def{}],
parameters = [] :: [term()],
attachments = [] :: [term()]
attachments = [] :: [term()],

call_ref :: atom(),
reference_ops :: #reference_config{},
loadbalance :: atom(),
source_pid :: pid(),
transport_pid :: pid()

}).

-record(consumer_config, {
@@ -96,15 +118,24 @@
application,
dubbo = <<"2.5.3">>,
methods = [],
side = <<"provider">>
side = <<"provider">>,
impl_handle
}).

-record(invoker,{
url,
handler
}).


-record(interface_info, {interface, loadbalance}).
-record(interface_info, {interface, loadbalance, protocol}).

-record(interface_list, {interface, pid, connection_info}).
%%-record(provider_node_list, {host_flag, pid, weight, readonly = false}).
-record(connection_info, {host_flag, pid, weight, readonly = false}).

-type dubbo_request() :: #dubbo_request{}.
-type dubbo_response() :: #dubbo_response{}.
-type dubbo_response() :: #dubbo_response{}.
-type invocation():: #dubbo_rpc_invocation{}.

%% @doc invoke return info
-type invoke_result() :: {ok, reference()}| {ok, reference(), Data :: any(), RpcContent :: list()}| {error, Reason :: timeout|no_provider|any()}.
@@ -20,7 +20,16 @@

-define(TRAFFIC_CONTROL, traffic_control).

-define(SERVICE_EXPORT_TABLE,dubbo_service_export).

-record(dubbo_url, {scheme, user_info, host, port, path, parameters, fragment}).
-record(dubbo_url, {
scheme :: binary() ,
user_info :: binary(),
host:: binary(),
port::integer(),
path:: binary(),
parameters::map(),
fragment::binary()
}).

-record(dubbo_invoker, {host_flag, handle}).
@@ -30,7 +30,7 @@ public class App {
public static void main(String[] args) throws IOException {
System.out.println("将要监听服务");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
new String[]{"applicationProvider.xml"});
new String[]{"applicationConsumer.xml"});
context.start();
UserOperator userOperator = (UserOperator) context.getBean("userInterface");
UserInfo result = userOperator.getUserInfo("hh-bb");
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<dubbo:application name="hello-world"/><!-- 注册地址 -->
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<dubbo:protocol name="dubbo" port="20880"/>

<dubbo:reference id="userInterface" interface="org.apache.dubbo.erlang.sample.service.facade.UserOperator" retries="0" />
</beans>
@@ -10,8 +10,8 @@

<dubbo:consumer check="false" timeout="300000" id="dubboConsumerConfig" retries="0"/>

<!-- <bean id="userService" class="org.apache.dubbo.erlang.sample.service.impl.UserOperatorImpl"/>-->
<!-- <dubbo:service interface="org.apache.dubbo.erlang.sample.service.facade.UserOperator" ref="userService"/>-->
<bean id="userService" class="org.apache.dubbo.erlang.sample.service.impl.UserOperatorImpl"/>
<dubbo:service interface="org.apache.dubbo.erlang.sample.service.facade.UserOperator" ref="userService"/>

<dubbo:reference id="userInterface" interface="org.apache.dubbo.erlang.sample.service.facade.UserOperator" retries="0" />
<!-- <dubbo:reference id="userInterface" interface="org.apache.dubbo.erlang.sample.service.facade.UserOperator" retries="0" />-->
</beans>
@@ -67,7 +67,7 @@ getUserInfo(Arg0, RequestOption)->
]
},
Request = dubbo_adapter:reference(Data),
dubbo_invoker_old:invoke_request(?CURRENT_CLASS_NAME,Request,RequestOption).
dubbo_invoker:invoke_request(?CURRENT_CLASS_NAME,Request,RequestOption).


-spec genUserId()->
@@ -96,7 +96,7 @@ genUserId( RequestOption)->
]
},
Request = dubbo_adapter:reference(Data),
dubbo_invoker_old:invoke_request(?CURRENT_CLASS_NAME,Request,RequestOption).
dubbo_invoker:invoke_request(?CURRENT_CLASS_NAME,Request,RequestOption).


-spec queryUserInfo(Arg0::#userInfoRequest{})->
@@ -127,7 +127,7 @@ queryUserInfo(Arg0, RequestOption)->
]
},
Request = dubbo_adapter:reference(Data),
dubbo_invoker_old:invoke_request(?CURRENT_CLASS_NAME,Request,RequestOption).
dubbo_invoker:invoke_request(?CURRENT_CLASS_NAME,Request,RequestOption).


-spec queryUserList(Arg0::list())->
@@ -158,5 +158,5 @@ queryUserList(Arg0, RequestOption)->
]
},
Request = dubbo_adapter:reference(Data),
dubbo_invoker_old:invoke_request(?CURRENT_CLASS_NAME,Request,RequestOption).
dubbo_invoker:invoke_request(?CURRENT_CLASS_NAME,Request,RequestOption).

@@ -1,13 +1,20 @@
%%%-------------------------------------------------------------------
%%% @author dlive
%%% @copyright (C) 2018, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 28. Feb 2018 10:57 PM
%%%-------------------------------------------------------------------
%%------------------------------------------------------------------------------
%% Licensed to the Apache Software Foundation (ASF) under one or more
%% contributor license agreements. See the NOTICE file distributed with
%% this work for additional information regarding copyright ownership.
%% The ASF licenses this file to You under the Apache License, Version 2.0
%% (the "License"); you may not use this file except in compliance with
%% the License. You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%------------------------------------------------------------------------------
-module(api_gateway_handle).
-author("dlive").

-include_lib("dubbo_sample_service/include/dubbo_sample_service.hrl").

@@ -28,7 +28,7 @@ reference(Data) ->
mid = dubbo_id_generator:gen_id(),
data = Data,
mversion = <<"0.0.0">>,
serialize_type = serialize_value(application:get_env(dubboerl, protocol, hessian))
serialize_type = serialize_value(application:get_env(dubboerl, serialization, hessian))
}.

serialize_value(json) ->

0 comments on commit af4b990

Please sign in to comment.