Skip to content
Permalink
Browse files
first commit
  • Loading branch information
Dlive committed Oct 17, 2018
0 parents commit ecf6f800c51ca155008fc851167b97afd3a1b807
Show file tree
Hide file tree
Showing 56 changed files with 6,552 additions and 0 deletions.
@@ -0,0 +1,18 @@
_*
.eunit
*.o
*.beam
*.plt
*.swp
*.swo
.erlang.cookie
ebin
log
erl_crash.dump
.rebar
logs
_build
.idea
.rebar
target
*.iml
@@ -0,0 +1,45 @@
## 开发

```
./rebar3 eunit -m dubbo_zookeeper_tests
dubbo_zookeeper:register_consumer(<<"com.ifcoder.demo.facade.User">>,[]).
iProcessData:call_object().
scherdule:call_object().
./rebar3 shell --apps "testdubboerl"
dubboerl:init().
```
### eunit Test
./rebar3 eunit -m dubbo_zookeeper_tests
./rebar3 eunit -m de_codec_tests

## 服务注册流程

### 消费者注册



### 生产者注册



### 消费者调用

```
Option=[
sync,
{timeout,5000}
{attachments,[{<<"a">>,<<"b">>}]}
]
```




## Develop Log
21 LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Dlive

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,67 @@
dubboerl
=====
A Erlang framework for dubbo.

Feature
-----

* 支持Zookeeper注册中心
* 支持Hession serialize
* 支持Consumer
* 支持Provider
* sync invoker
* async invoker

Start
-----

参考demo [dubboerl_demo](https://github.com/DLive/dubboerl_demo)

#### Step1
Transfer java facede t
o erlang lib and add to you project dir.

#### Step2

configure dubbo refernce

```
{dubboerl,[
{zookeeper_list,[{"127.0.0.1",2181}]},
{application,<<"testdubboerl">>},
{consumer,[
{<<"me.dlive.dubboservice.service.IProcessData">>,[]}
]},
{provider,[
{scherdule_impl,scherdule_behaviour,<<"me.dlive.dubboservice.service.Scherdule">>,[]}
]}
]}
```
#### Step4
Init dubboerl application context

dubboerl:init().

#### Step5
Do your interface method invoker.

```
RequestPara = #testReq{name = <<"nameinfo">>,nick = <<"nickinfo">>,age = 10},
iProcessData:queryinfo(Info,[]).
```



Build
-----

$ rebar3 compile


release

$ ./rebar3 as dubboerl release -n dubboerl



@@ -0,0 +1,34 @@
[
%% SASL config {file, "log/sasl-error.log"}
{sasl, [
{sasl_error_logger, false},
{errlog_type, error},
{error_logger_mf_dir, "log/sasl-error.log"}, % Log directory
{error_logger_mf_maxbytes, 104857600}, % 100 MB max file size
{error_logger_mf_maxfiles, 5} % 5 files max
]},
{emysql,[
{lock_timeout,900000},
{default_timeout, 900000}

]},
{lager, [
{log_root, "./logs"},
{handlers, [
{lager_console_backend, debug},
{lager_file_backend, [{file, "error.log"}, {level, error}]},
{lager_file_backend, [{file, "console.log"}, {level, info}]}
]}
]},
{dubboerl,[
{zookeeper_list,[{"127.0.0.1",2181}]},
{application,<<"testdubboerl">>},
{consumer,[
{<<"com.ifcoder.demo.facade.User">>,[]}
]},
{provider,[
{user_impl,user_behaviour,<<"com.ifcoder.demo.facade.User">>,[]}
]}

]}
].
@@ -0,0 +1,36 @@
## Name of the node
##需要定义 -name android_connecion_1@logic1.mpush.paf
-name dubboerl@127.0.0.1

## Cookie for distributed erlang
-setcookie fb65338cf25a2d68a2da5207f718cdfa

## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
## (Disabled by default..use with caution!)
##-heart

## Enable kernel poll and a few async threads
+K true
##+A 5

## Increase number of concurrent ports/sockets
-env ERL_MAX_PORTS 10240000

## too many db tables
-env ERL_MAX_ETS_TABLES 125535

+P 3000000

## Tweak GC to run more often
-env ERL_FULLSWEEP_AFTER 30000


## +S 2

## erlang 端口上退 默认65535
+Q 2000000

-kernel inet_dist_listen_min 4370 inet_dist_listen_max 4388

## 调度类型
-sub true
@@ -0,0 +1,15 @@
%%%-------------------------------------------------------------------
%%% @author dlive
%%% @copyright (C) 2016, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 14. 十月 2016 下午4:29
%%%-------------------------------------------------------------------
-author("dlive").

-ifdef(DEBUG).
-define(RELOADER,true).
-else.
-define(RELOADER,false).
-endif.
@@ -0,0 +1,98 @@
%%%-------------------------------------------------------------------
%%% @author dlive
%%% @copyright (C) 2016, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 16. 十月 2016 下午11:38
%%%-------------------------------------------------------------------
-author("dlive").

-include("hessian.hrl").

-define(DUBBO_VERSION,<<"2.6.0">>).
-define(DUBBO_MEGIC, -9541). %% new version 16#dabb
-define(DUBBO_MEGIC_HIGH, 16#da). %% new version 16#da
-define(DUBBO_MEGIC_LOW, 16#bb). %% new version 16#bb

%% 序列化类型
-define(SERIALIZATION_HESSIAN,2).
-define(SERIALIZATION_FASTJSON,6).
-define(SERIALIZATION_KRYO,8).

-define(RESPONSE_WITH_EXCEPTION,0).
-define(RESPONSE_VALUE,1).
-define(RESPONSE_NULL_VALUE,2).


-define(RESPONSE_STATE_OK,20).

-define(REQUEST_TIME_OUT,5000).

-define(LINE_SEPERATOR,<<"\n"/utf8>>).

-record(dubbo_request,{
serialize_type = 2 ::integer(),
is_event = true ::boolean(),
is_twoway = false ::boolean(),
data ::null|dubbo_rpc_invocation,
mid ::integer(),
mversion ::string(),
error_msg ::string(),
state ::byte(),
decode_state
}).

-record(dubbo_response,{
serialize_type = 2 ::integer(),
is_event = true ::boolean(),
is_twoway = false ::boolean(),
data ::null|dubbo_rpc_invocation,
mid ::integer(),
mversion ::string(),
error_msg ::string(),
state ::byte(),
decode_state
}).

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

-record(consumer_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()
}).

-record(provider_config,{
protocol,
host,
port,
interface,
anyhost=true,
executes=1,
application,
dubbo= <<"2.5.3">>,
methods=[],
side= <<"provider">>
}).



-record(interface_list,{interface,pid,connection_info}).
-record(provider_node_list,{host_flag,connection_info}).
-record(connection_info,{connection_id,pid,weight,host_flag}).
@@ -0,0 +1,12 @@
%%%-------------------------------------------------------------------
%%% @author dlive
%%% @copyright (C) 2018, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 15. Apr 2018 9:10 PM
%%%-------------------------------------------------------------------
-author("dlive").


-type response_content() :: binary().
@@ -0,0 +1,16 @@
%%%-------------------------------------------------------------------
%%% @author dlive
%%% @copyright (C) 2018, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 22. Mar 2018 6:53 PM
%%%-------------------------------------------------------------------
-author("dlive").


-define(PROVIDER_IMPL_TABLE,provider_impl_table).

-define(PROVIDER_WORKER,provider_worker).

-define(TRAFFIC_CONTROL,traffic_control).

0 comments on commit ecf6f80

Please sign in to comment.