From 17fce5cc974055b760eb296b7ae031c502c4b413 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Thu, 26 Aug 2021 21:41:34 +0800 Subject: [PATCH] =?UTF-8?q?ft:=20=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 38 ++++++++++++++++++--------------- include/eArango.hrl | 4 ++-- rebar.config | 3 +-- src/agVstCli/agMiscUtils.erl | 10 ++++----- src/agVstCli/agSslAgencyExm.erl | 2 +- src/agVstCli/agTcpAgencyExm.erl | 2 +- src/agVstCli/agVstCli.erl | 6 +++--- src/eArango.app.src | 2 +- src/eArango_sup.erl | 4 ++-- 9 files changed, 37 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index f3cf49f..bbaa8d4 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,34 @@ # eArango + arangodb erlang driver - erlang otp21.2+ arangodb 3.6.2 3.7 - + erlang otp21.2+ arangodb 3.6.2 3.7 3.9 + # Feature - Efficient, fast and easy to use. - 1. To make this driver as efficient as possible, customizations encapsulate an HTTP1.1 client(agVstCli) with connection pooling. - Comparisons between packaged agVstCli and similar HTTP client tests are available:[Address](https://github.com/SisMaker/httpc_bench) - 2. This driver can use connection pooling or simply establish multiple connections in a single process (non-connection pooling mode) for various data operations. - Synchronous and asynchronous operations are supported when using connection pooling, - and you need to save the requestId extra if you want to use asynchronous operations Waiting for the received data to return, - the API encapsulated by the current driver all USES synchronous operation, and can be modified if asynchronous operation is needed. - Only synchronous operations are supported for single-process operations. - In single-process mode, compared with connection pooling mode, data replication between processes can be reduced once. - For operation of large amount of data, database connection can be established separately in data management process instead of connection pooling. - 3. The connection pooling mode and connectionless pool mode API interface ensures the identity, does not need to be treated differently, - and is easy to understand and change between connection pooling mode and connectionless pool mode. + +Efficient, fast and easy to use. + +1. This driver can use connection pooling or simply establish multiple connections in a single process (non-connection + pooling mode) for various data operations. Synchronous and asynchronous operations are supported when using + connection pooling, and you need to save the requestId extra if you want to use asynchronous operations Waiting for + the received data to return, the API encapsulated by the current driver all USES synchronous operation, and can be + modified if asynchronous operation is needed. Only synchronous operations are supported for single-process + operations. In single-process mode, compared with connection pooling mode, data replication between processes can be + reduced once. For operation of large amount of data, database connection can be established separately in data + management process instead of connection pooling. +2. The connection pooling mode and connectionless pool mode API interface ensures the identity, does not need to be + treated differently, and is easy to understand and change between connection pooling mode and connectionless pool + mode. # Batch requests are not supported + https://www.arangodb.com/docs/stable/http/batch-request.html # compile - rebar get-deps; rebar compile or rebar3 compile - Note: If you build Jiffy on The Windows platform, you will need to set up an additional compilation environment. [See jiffy for details](https://github.com/SisMaker/erlUtils/tree/master/src/docs) + + rebar3 compile # how to use - rebar: erl -pa ./ebin -pa ./deps/jiffy/ebin or + revar3: rebar3 shell Non-connection pooling mode Make a connection first diff --git a/include/eArango.hrl b/include/eArango.hrl index 9a80b10..3d47ba8 100644 --- a/include/eArango.hrl +++ b/include/eArango.hrl @@ -2,9 +2,9 @@ -define(AgGet, 1). -define(AgPost, 2). -define(AgPut, 3). --define(AgHead, 4). %% (not used in VPP) +-define(AgHead, 4). %% (not used in VPP, 即主体是存储为VelocyPack的对象。) -define(AgPatch, 5). --define(AgOptions, 6). %% (not used in VPP) +-define(AgOptions, 6). %% (not used in VPP, 即主体是存储为VelocyPack的对象。) -define(AgDefQuery, #{}). -define(AgDefHeader, #{}). diff --git a/rebar.config b/rebar.config index 6acd5a4..7e97539 100644 --- a/rebar.config +++ b/rebar.config @@ -1,7 +1,6 @@ {erl_opts, [{i, "include"}]}. {deps, [ - {eVPack, {git, "http://192.168.0.88:53000/SisMaker/eVPack.git", {branch, master}}} - %%{jiffy, {git, "http://192.168.0.88:53000/SisMaker/jiffy.git", {branch, master}}} + {eVPack, {git, "http://sismaker.tpddns.cn:53000/SisMaker/eVPack.git", {branch, master}}} ]}. diff --git a/src/agVstCli/agMiscUtils.erl b/src/agVstCli/agMiscUtils.erl index e1c4f4d..0e56db5 100644 --- a/src/agVstCli/agMiscUtils.erl +++ b/src/agVstCli/agMiscUtils.erl @@ -10,7 +10,7 @@ , agencyOpts/1 , warnMsg/3 , getListValue/3 - , randomElement/1 + , randElement/1 , toBinary/1 ]). @@ -71,7 +71,7 @@ getListValue(Key, List, Default) -> case lists:keyfind(Key, 1, List) of false -> Default; - {Key, Value} -> + {_Key, Value} -> Value end. @@ -79,10 +79,10 @@ getListValue(Key, List, Default) -> warnMsg(Tag, Format, Data) -> error_logger:warning_msg("[~p] " ++ Format, [Tag | Data]). --spec randomElement([term()]) -> term(). -randomElement([X]) -> +-spec randElement([term()]) -> term(). +randElement([X]) -> X; -randomElement([_ | _] = List) -> +randElement([_ | _] = List) -> T = list_to_tuple(List), element(rand:uniform(tuple_size(T)), T). diff --git a/src/agVstCli/agSslAgencyExm.erl b/src/agVstCli/agSslAgencyExm.erl index f099d3a..dd77a9b 100644 --- a/src/agVstCli/agSslAgencyExm.erl +++ b/src/agVstCli/agSslAgencyExm.erl @@ -39,7 +39,7 @@ system_get_state({_Parent, SrvState, _CliState}) -> {ok, SrvState}. -spec system_terminate(term(), pid(), [], term()) -> none(). -system_terminate(Reason, _Parent, _Debug, {_Parent, SrvState, CliState}) -> +system_terminate(Reason, _ParentS, _Debug, {_Parent, SrvState, CliState}) -> terminate(Reason, SrvState, CliState). safeRegister(ServerName) -> diff --git a/src/agVstCli/agTcpAgencyExm.erl b/src/agVstCli/agTcpAgencyExm.erl index e98be13..befd7d8 100644 --- a/src/agVstCli/agTcpAgencyExm.erl +++ b/src/agVstCli/agTcpAgencyExm.erl @@ -39,7 +39,7 @@ system_get_state({_Parent, SrvState, _CliState}) -> {ok, SrvState}. -spec system_terminate(term(), pid(), [], term()) -> none(). -system_terminate(Reason, _Parent, _Debug, {_Parent, SrvState, CliState}) -> +system_terminate(Reason, _ParentS, _Debug, {_Parent, SrvState, CliState}) -> terminate(Reason, SrvState, CliState). safeRegister(ServerName) -> diff --git a/src/agVstCli/agVstCli.erl b/src/agVstCli/agVstCli.erl index d4cdf37..4e84987 100644 --- a/src/agVstCli/agVstCli.erl +++ b/src/agVstCli/agVstCli.erl @@ -172,11 +172,11 @@ receiveSslData(RecvState, Socket) -> {?AgMDone, MsgBin} -> {ok, MsgBin}; {?AgCHeader, NewRecvState} -> - receiveTcpData(NewRecvState, Socket); + receiveSslData(NewRecvState, Socket); {?AgCBodyStart, NewRecvState} -> - receiveTcpData(NewRecvState, Socket); + receiveSslData(NewRecvState, Socket); {?AgCBodyGoOn, NewRecvState} -> - receiveTcpData(NewRecvState, Socket) + receiveSslData(NewRecvState, Socket) end; {ssl_closed, Socket} -> disConnDb(Socket), diff --git a/src/eArango.app.src b/src/eArango.app.src index 3789437..6444f39 100644 --- a/src/eArango.app.src +++ b/src/eArango.app.src @@ -1,5 +1,5 @@ {application, eArango, - [{description, "An OTP application"}, + [{description, "ArangoDB erlang's driver"}, {vsn, "0.1.0"}, {registered, []}, {mod, {eArango_app, []}}, diff --git a/src/eArango_sup.erl b/src/eArango_sup.erl index ed94d64..beb1164 100644 --- a/src/eArango_sup.erl +++ b/src/eArango_sup.erl @@ -25,6 +25,6 @@ start_link() -> init([]) -> SupFlags = #{strategy => one_for_one, intensity => 100, period => 3600}, PoolMgrSpec = #{id => agAgencyPoolMgrExm, start => {agAgencyPoolMgrExm, start_link, [?agAgencyPoolMgr, [], []]}, restart => permanent, shutdown => infinity, type => worker, modules => [agAgencyPoolMgrExm]}, - HttpCliSupSpec = #{id => agAgencyPool_sup, start => {agAgencyPool_sup, start_link, []}, restart => permanent, shutdown => infinity, type => supervisor, modules => [agAgencyPool_sup]}, - {ok, {SupFlags, [PoolMgrSpec, HttpCliSupSpec]}}. + CliSupSpec = #{id => agAgencyPool_sup, start => {agAgencyPool_sup, start_link, []}, restart => permanent, shutdown => infinity, type => supervisor, modules => [agAgencyPool_sup]}, + {ok, {SupFlags, [PoolMgrSpec, CliSupSpec]}}.