Bladeren bron

代码buf fix 以及部分调整

erlArango_v1
SisMaker 5 jaren geleden
bovenliggende
commit
1ac5a82aee
32 gewijzigde bestanden met toevoegingen van 184 en 39 verwijderingen
  1. +1
    -1
      include/agHttpCli.hrl
  2. +2
    -0
      src/arangoApi/agAdminMonitor.erl
  3. +2
    -0
      src/arangoApi/agAnalyzers.erl
  4. +2
    -0
      src/arangoApi/agAqlMod.erl
  5. +2
    -0
      src/arangoApi/agAsyncResultHandling.erl
  6. +2
    -0
      src/arangoApi/agBulkImportExport.erl
  7. +2
    -0
      src/arangoApi/agCluster.erl
  8. +2
    -0
      src/arangoApi/agCollections.erl
  9. +2
    -0
      src/arangoApi/agDbMgr.erl
  10. +2
    -0
      src/arangoApi/agDocuments.erl
  11. +2
    -0
      src/arangoApi/agEdges.erl
  12. +2
    -0
      src/arangoApi/agEndPoints.erl
  13. +2
    -0
      src/arangoApi/agFoxxServices.erl
  14. +2
    -0
      src/arangoApi/agGeneralGraphs.erl
  15. +2
    -0
      src/arangoApi/agHotBackup.erl
  16. +2
    -0
      src/arangoApi/agIndexes.erl
  17. +2
    -0
      src/arangoApi/agMiscFun.erl
  18. +2
    -0
      src/arangoApi/agRepairJobs.erl
  19. +2
    -0
      src/arangoApi/agReplication.erl
  20. +2
    -0
      src/arangoApi/agSimpleQueries.erl
  21. +2
    -0
      src/arangoApi/agTasks.erl
  22. +2
    -0
      src/arangoApi/agTransactions.erl
  23. +2
    -0
      src/arangoApi/agTraversals.erl
  24. +2
    -0
      src/arangoApi/agUserMgr.erl
  25. +2
    -0
      src/arangoApi/agViews.erl
  26. +1
    -1
      src/httpCli/agAgencyPoolMgrIns.erl
  27. +10
    -16
      src/httpCli/agHttpCli.erl
  28. +5
    -5
      src/httpCli/agHttpProtocol.erl
  29. +7
    -1
      src/httpCli/agMiscUtils.erl
  30. +4
    -1
      src/httpCli/agSslAgencyIns.erl
  31. +4
    -1
      src/httpCli/agTcpAgencyIns.erl
  32. +104
    -13
      src/user_default.erl

+ 1
- 1
include/agHttpCli.hrl Bestand weergeven

@ -17,7 +17,7 @@
-define(DEFAULT_RECONNECT_MAX, 120000).
-define(DEFAULT_TIMEOUT, infinity).
-define(DEFAULT_PID, self()).
-define(DEFAULT_SOCKET_OPTS, [binary, {active, true}, {delay_send, true}, {nodelay, true}, {keepalive, true}, {recbuf, 1048576}, {send_timeout, 5000}, {send_timeout_close, true}]).
-define(DEFAULT_SOCKET_OPTS, [binary, {active, true}, {nodelay, true}, {delay_send, true}, {keepalive, true}, {recbuf, 2097152}, {send_timeout, 5000}, {send_timeout_close, true}]).
-define(GET_FROM_LIST(Key, List), agMiscUtils:getListValue(Key, List, undefined)).
-define(GET_FROM_LIST(Key, List, Default), agMiscUtils:getListValue(Key, List, Default)).

+ 2
- 0
src/arangoApi/agAdminMonitor.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agAdminMonitor).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html

+ 2
- 0
src/arangoApi/agAnalyzers.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agAnalyzers).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/analyzers.html

+ 2
- 0
src/arangoApi/agAqlMod.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agAqlMod).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:

+ 2
- 0
src/arangoApi/agAsyncResultHandling.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agAsyncResultHandling).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/async-results-management.html

+ 2
- 0
src/arangoApi/agBulkImportExport.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agBulkImportExport).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/bulk-imports.html

+ 2
- 0
src/arangoApi/agCluster.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agCluster).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
%% doc_address:https://www.arangodb.com/docs/stable/http/cluster.html

+ 2
- 0
src/arangoApi/agCollections.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agCollections).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/collection.html

+ 2
- 0
src/arangoApi/agDbMgr.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agDbMgr).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
%% doc_address:https://www.arangodb.com/docs/stable/http/database-database-management.html

+ 2
- 0
src/arangoApi/agDocuments.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agDocuments).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
%% doc_address:https://www.arangodb.com/docs/stable/http/document.html

+ 2
- 0
src/arangoApi/agEdges.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agEdges).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
%% doc_address:https://www.arangodb.com/docs/stable/http/edge.html

+ 2
- 0
src/arangoApi/agEndPoints.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agEndPoints).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/endpoints.html

+ 2
- 0
src/arangoApi/agFoxxServices.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agFoxxServices).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/foxx.html

+ 2
- 0
src/arangoApi/agGeneralGraphs.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agGeneralGraphs).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
%% doc_address:https://www.arangodb.com/docs/stable/http/gharial.html

+ 2
- 0
src/arangoApi/agHotBackup.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agHotBackup).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/hot-backup.html

+ 2
- 0
src/arangoApi/agIndexes.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agIndexes).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/indexes.html

+ 2
- 0
src/arangoApi/agMiscFun.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agMiscFun).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
%% doc_address:https://www.arangodb.com/docs/stable/http/miscellaneous-functions.html

+ 2
- 0
src/arangoApi/agRepairJobs.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agRepairJobs).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
%% doc_address:https://www.arangodb.com/docs/stable/http/repairs.html

+ 2
- 0
src/arangoApi/agReplication.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agReplication).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/3.6/http/replications.html

+ 2
- 0
src/arangoApi/agSimpleQueries.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agSimpleQueries).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/simple-query.html

+ 2
- 0
src/arangoApi/agTasks.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agTasks).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/traversal.html

+ 2
- 0
src/arangoApi/agTransactions.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agTransactions).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/transaction.html

+ 2
- 0
src/arangoApi/agTraversals.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agTraversals).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/traversal.html

+ 2
- 0
src/arangoApi/agUserMgr.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agUserMgr).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/user-management.html

+ 2
- 0
src/arangoApi/agViews.erl Bestand weergeven

@ -1,6 +1,8 @@
-module(agViews).
-include("erlArango.hrl").
-compile(inline).
-compile({inline_size, 128}).
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/views.html

+ 1
- 1
src/httpCli/agAgencyPoolMgrIns.erl Bestand weergeven

@ -112,7 +112,7 @@ agencyMod(_) ->
agencySpec(ServerMod, ServerName, Args) ->
%% TODO spawn_opt
StartFunc = {ServerMod, start_link, [ServerName, Args, [{min_heap_size, 5000}, {min_bin_vheap_size, 100000}, {fullsweep_after, 500}]]},
StartFunc = {ServerMod, start_link, [ServerName, Args, [{min_heap_size, 10240}, {min_bin_vheap_size, 524288}, {fullsweep_after, 512}]]},
{ServerName, StartFunc, transient, infinity, worker, [ServerMod]}.
-spec startChildren(atom(), protocol(), poolSize(), agencyOpts()) -> ok.

+ 10
- 16
src/httpCli/agHttpCli.erl Bestand weergeven

@ -14,7 +14,7 @@
, castAgency/6
, castAgency/7
, castAgency/8
, receiveResponse/2
, receiveRequestRet/2
%% API
, startPool/2
@ -41,7 +41,7 @@ callAgency(PoolNameOrSocket, Method, Path, Headers, Body, IsSystem) ->
callAgency(PoolNameOrSocket, Method, Path, Headers, Body, IsSystem, Timeout) ->
case castAgency(PoolNameOrSocket, Method, Path, Headers, Body, self(), IsSystem, Timeout) of
{ok, RequestId, MonitorRef} ->
receiveResponse(RequestId, MonitorRef);
receiveRequestRet(RequestId, MonitorRef);
{error, _Reason} = Err ->
Err;
Ret ->
@ -124,14 +124,14 @@ castAgency(PoolNameOrSocket, Method, Path, Headers, Body, Pid, IsSystem, Timeout
end
end.
-spec receiveResponse(requestId(), reference()) -> term() | {error, term()}.
receiveResponse(RequestId, MonitorRef) ->
-spec receiveRequestRet(requestId(), reference()) -> term() | {error, term()}.
receiveRequestRet(RequestId, MonitorRef) ->
receive
#miRequestRet{requestId = RequestId, reply = Reply} ->
erlang:demonitor(MonitorRef),
case Reply of
{ok, Headers, Body} ->
{ok, Headers, jiffy:decode(Body, [return_maps])};
{ok, Headers, jiffy:decode(Body, [return_maps, copy_strings])};
_ ->
Reply
end;
@ -145,7 +145,7 @@ receiveTcpData(RecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod) ->
{tcp, Socket, Data} ->
try agHttpProtocol:response(RecvState, Rn, RnRn, Data, IsHeadMethod) of
{done, #recvState{headers = Headers, body = Body}} ->
{ok, Headers, jiffy:decode(Body, [return_maps])};
{ok, Headers, jiffy:decode(Body, [return_maps, copy_strings])};
{ok, NewRecvState} ->
receiveTcpData(NewRecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod);
{error, Reason} ->
@ -165,10 +165,7 @@ receiveTcpData(RecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod) ->
{error, tcp_closed};
{tcp_error, Socket, Reason} ->
disConnectDb(Socket),
{error, {tcp_error, Reason}};
_Msg ->
?WARN(receiveTcpData, "receive unexpect msg: ~p~n", [_Msg]),
receiveTcpData(RecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod)
{error, {tcp_error, Reason}}
end.
-spec receiveSslData(recvState() | undefined, socket(), reference() | undefined, binary:cp(), binary:cp(), boolean()) -> {ok, term(), term()} | {error, term()}.
@ -177,9 +174,9 @@ receiveSslData(RecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod) ->
{ssl, Socket, Data} ->
try agHttpProtocol:response(RecvState, Rn, RnRn, Data, IsHeadMethod) of
{done, #recvState{headers = Headers, body = Body}} ->
{ok, Headers, jiffy:decode(Body, [return_maps])};
{ok, Headers, jiffy:decode(Body, [return_maps, copy_strings])};
{ok, NewRecvState} ->
receiveTcpData(NewRecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod);
receiveSslData(NewRecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod);
{error, Reason} ->
?WARN(receiveSslData, "handle tcp data error: ~p ~n", [Reason]),
disConnectDb(Socket),
@ -197,10 +194,7 @@ receiveSslData(RecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod) ->
{error, ssl_closed};
{ssl_error, Socket, Reason} ->
disConnectDb(Socket),
{error, {ssl_error, Reason}};
_Msg ->
?WARN(receiveSslData, "receive unexpect msg: ~p~n", [_Msg]),
receiveSslData(RecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod)
{error, {ssl_error, Reason}}
end.
-spec startPool(poolName(), dbCfgs()) -> ok | {error, pool_name_used}.

+ 5
- 5
src/httpCli/agHttpProtocol.erl Bestand weergeven

@ -59,7 +59,7 @@ response(undefined, Rn, RnRn, Data, IsHeadMethod) ->
{chunked, Headers, Body} ->
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode < 200 andalso StatusCode >= 100) of
true ->
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = Rest}};
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = <<"{}">>}};
_ ->
RecvState = #recvState{stage = body, contentLength = chunked, statusCode = StatusCode, headers = Headers},
response(RecvState, Rn, RnRn, Body, IsHeadMethod)
@ -75,7 +75,7 @@ response(undefined, Rn, RnRn, Data, IsHeadMethod) ->
true ->
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode < 200 andalso StatusCode >= 100) of
true ->
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}};
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = <<"{}">>}};
_ ->
{ok, #recvState{stage = body, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}}
end
@ -126,7 +126,7 @@ response(#recvState{stage = header, body = OldBody}, Rn, RnRn, Data, IsHeadMetho
{chunked, Headers, Rest} ->
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode < 200 andalso StatusCode >= 100) of
true ->
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = Rest}};
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = 0, body = <<"{}">>}};
_ ->
RecvState = #recvState{stage = body, contentLength = chunked, statusCode = StatusCode, headers = Headers},
response(RecvState, Rn, RnRn, Rest, IsHeadMethod)
@ -142,7 +142,7 @@ response(#recvState{stage = header, body = OldBody}, Rn, RnRn, Data, IsHeadMetho
true ->
case IsHeadMethod orelse StatusCode == 204 orelse StatusCode == 304 orelse (StatusCode < 200 andalso StatusCode >= 100) of
true ->
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}};
{done, #recvState{stage = done, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = <<"{}">>}};
_ ->
{ok, #recvState{stage = body, statusCode = StatusCode, headers = Headers, contentLength = ContentLength, body = Body}}
end
@ -167,7 +167,7 @@ splitHeaders(Data, Rn, RnRn) ->
[Headers, Body] ->
HeadersList = binary:split(Headers, Rn, [global]),
ContentLength = contentLength(HeadersList),
{ContentLength, HeadersList, Body}
{ContentLength, Headers, Body}
end.
contentLength([]) ->

+ 7
- 1
src/httpCli/agMiscUtils.erl Bestand weergeven

@ -13,6 +13,7 @@
, randomElement/1
, toBinary/1
, spellQueryPars/1
, getHeaderValue/2
, lookHeader/2
]).
@ -107,9 +108,14 @@ spellQueryPars([{Key, Value} | Tail]) ->
TailBinary = <<<<"&", (toBinary(OtherKey))/binary, "=", (toBinary(OtherValue))/binary>> || {OtherKey, OtherValue} <- Tail>>,
<<FirstBinary/binary, TailBinary/binary>>.
-spec getHeaderValue(binary(), binary()) -> binary().
getHeaderValue(Header, HeaderBin) ->
HeadersList = binary:split(HeaderBin, <<"\r\n">>, [global]),
lookHeader(Header, HeadersList).
-spec lookHeader(binary, list()) -> binary().
lookHeader(_Header, []) ->
<<>>;
undefined;
lookHeader(Header, [H | T]) ->
case binary:split(H, <<": ">>) of
[Header, Value] ->

+ 4
- 1
src/httpCli/agSslAgencyIns.erl Bestand weergeven

@ -188,7 +188,7 @@ overDealQueueRequest(#miRequest{method = Method, path = Path, headers = Headers,
-spec overReceiveSslData(srvState(), cliState()) -> {ok, srvState(), cliState()}.
overReceiveSslData(#srvState{poolName = PoolName, serverName = ServerName, rn = Rn, rnrn = RnRn, socket = Socket} = SrvState,
#cliState{isHeadMethod = IsHeadMethod, backlogNum = BacklogNum, curInfo = CurInfo, requestsOut = RequestsOut, recvState = RecvState} = CliState) ->
#cliState{isHeadMethod = IsHeadMethod, backlogNum = BacklogNum, curInfo = CurInfo, requestsIn = RequestsIn, requestsOut = RequestsOut, recvState = RecvState} = CliState) ->
receive
{ssl, Socket, Data} ->
try agHttpProtocol:response(RecvState, Rn, RnRn, Data, IsHeadMethod) of
@ -245,6 +245,9 @@ overReceiveSslData(#srvState{poolName = PoolName, serverName = ServerName, rn =
{ssl_error, Socket, Reason} ->
ssl:close(Socket),
agAgencyUtils:dealClose(SrvState, CliState, {error, {ssl_error, Reason}});
#miRequest{} = MiRequest ->
agAgencyUtils:addQueue(RequestsIn, MiRequest),
overReceiveSslData(SrvState, CliState#cliState{requestsIn = RequestsIn + 1, backlogNum = BacklogNum + 1});
_Msg ->
?WARN(overReceiveSslData, "receive unexpect msg: ~p~n", [_Msg]),
overReceiveSslData(SrvState, CliState)

+ 4
- 1
src/httpCli/agTcpAgencyIns.erl Bestand weergeven

@ -187,7 +187,7 @@ overDealQueueRequest(#miRequest{method = Method, path = Path, headers = Headers,
-spec overReceiveTcpData(srvState(), cliState()) -> {ok, srvState(), cliState()}.
overReceiveTcpData(#srvState{poolName = PoolName, serverName = ServerName, rn = Rn, rnrn = RnRn, socket = Socket} = SrvState,
#cliState{isHeadMethod = IsHeadMethod, backlogNum = BacklogNum, curInfo = CurInfo, requestsOut = RequestsOut, recvState = RecvState} = CliState) ->
#cliState{isHeadMethod = IsHeadMethod, backlogNum = BacklogNum, curInfo = CurInfo, requestsIn = RequestsIn, requestsOut = RequestsOut, recvState = RecvState} = CliState) ->
receive
{tcp, Socket, Data} ->
try agHttpProtocol:response(RecvState, Rn, RnRn, Data, IsHeadMethod) of
@ -244,6 +244,9 @@ overReceiveTcpData(#srvState{poolName = PoolName, serverName = ServerName, rn =
{tcp_error, Socket, Reason} ->
gen_tcp:close(Socket),
agAgencyUtils:dealClose(SrvState, CliState, {error, {tcp_error, Reason}});
#miRequest{} = MiRequest ->
agAgencyUtils:addQueue(RequestsIn, MiRequest),
overReceiveTcpData(SrvState, CliState#cliState{requestsIn = RequestsIn + 1, backlogNum = BacklogNum + 1});
_Msg ->
?WARN(overReceiveTcpData, "receive unexpect msg: ~p~n", [_Msg]),
overReceiveTcpData(SrvState, CliState)

+ 104
- 13
src/user_default.erl Bestand weergeven

@ -10,23 +10,21 @@ start() ->
agHttpCli:startPool(tt, [{poolSize, 10}], []).
tt(C, N) ->
application:start(erlArango),
agHttpCli:startPool(tt, [{poolSize, 100}], []),
Request = {<<"GET">>, <<"/_api/database/current">>, [], []},
io:format("IMY********************** start time ~p~n", [erlang:system_time(millisecond)]),
[spawn(test, test, [N, Request]) || _Idx <- lists:seq(1, C)].
application:ensure_all_started(erlArango),
agHttpCli:startPool(tt, [{poolSize, 16}], []),
StartTime = erlang:system_time(millisecond),
io:format("IMY********************** started~n"),
[spawn(?MODULE, test, [N, StartTime]) || _Idx <- lists:seq(1, C)].
%%test(N, Request).
%% /_api/database
test(0, Request) ->
R1 = {<<"GET">>, <<"/_api/database">>, [], []},
agHttpCli:callAgency(tt, R1, 5000),
io:format("IMY********************** test over ~p~n", [erlang:system_time(millisecond)]);
test(N, Request) ->
erlang:put(cnt, N),
agHttpCli:callAgency(tt, Request, 5000),
test(N - 1, Request).
test(0, StartTime) ->
agDbMgr:curDbList(tt),
io:format("IMY******test over use time ~p~n", [erlang:system_time(millisecond) - StartTime]);
test(N, StartTime) ->
agDbMgr:curDbList(tt),
test(N - 1, StartTime).
%% tt(C, N) ->
%% application:start(erlArango),
@ -64,3 +62,96 @@ tcjx(N, Args1) ->
Args = {[{name, ffd}, {tet, "fdsff"}, {<<"dfdf">>, 131245435346}]},
jiffy:encode(Args),
tcjx(N - 1, Args1).
-define(HeadBin, <<"X-Content-Type-Options: nosniff\r\nEtag: \"_aKwJ_tm--E\"\r\nServer: ArangoDB\r\nConnection: Keep-Alive\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 178">>).
th1(0, Fun, Rn) ->
?MODULE:Fun(?HeadBin, Rn);
th1(N, Fun, Rn) ->
?MODULE:Fun(?HeadBin, Rn),
th1(N - 1, Fun, Rn).
th2(0, Fun, Cl, Rn) ->
?MODULE:Fun(?HeadBin, Cl, Rn);
th2(N, Fun, Cl, Rn) ->
?MODULE:Fun(?HeadBin, Cl, Rn),
th2(N - 1, Fun, Cl, Rn).
head1(Headers, Rn) ->
HeadersList = binary:split(Headers, Rn, [global]),
contentLength(HeadersList).
head2(Headers, _Rn) ->
HeadersList = binary:split(Headers, <<"\r\n">>, [global]),
contentLength(HeadersList).
head3(Headers, CL, Rn) ->
case binary:split(Headers, CL) of
[_, Rest1] ->
case binary:split(Rest1, Rn) of
[InBin, _Rest2] ->
binary_to_integer(InBin);
[InBin] ->
binary_to_integer(InBin)
end;
_ ->
0
end.
%% binary:compile_pattern(<<"\r\n">>)
%% binary:compile_pattern(<<"Content-Length: ">>)
head4(Headers, _CL, _Rn) ->
case binary:split(Headers, <<"Content-Length: ">>) of
[_, Rest1] ->
case binary:split(Rest1, <<"\r\n">>) of
[InBin, _Rest2] ->
binary_to_integer(InBin);
[InBin] ->
binary_to_integer(InBin)
end;
_ ->
0
end.
contentLength([]) ->
undefined;
contentLength([<<"Content-Length: ", Rest/binary>> | _T]) ->
binary_to_integer(Rest);
contentLength([<<"content-length: ", Rest/binary>> | _T]) ->
binary_to_integer(Rest);
contentLength([<<"Transfer-Encoding: chunked">> | _T]) ->
chunked;
contentLength([<<"transfer-encoding: chunked">> | _T]) ->
chunked;
contentLength([_ | T]) ->
contentLength(T).
-define(BodyBin1, <<"{\"_key\":\"01J\",\"_id\":\"airports/01J\",\"_rev\":\"_aKwJ_tm--E\",\"name\":\"Hilliard Airpark\",\"city\":\"Hilliard\",\"state\":\"FL\",\"country\":\"USA\",\"lat\":30.6880125,\"long\":-81.90594389,\"vip\":false}">>).
-define(BodyBin2, <<"{\"_key\":\"01J\",\"_id\":\"airports/01J\",\"_rev\":\"_aPaBl7O--_\",\"name\":\"Hilliard Airpark\",\"city\":\"Hilliardfdfsdfdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffafdsfasdfdafsdafdsfsdafdsafdsfdsfdsafdsfdsfdsfhghfghfghgfhsdsdfdsfdsfdsffdfddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddggggggggggggggggggggggggggggggggggggggggg\",\"state\":\"FL\",\"country\":\"USAjjkjkjkfgjkgjfkdjgldgjldjglfdjglfjdljljrlejtrltjewltjrelwtjrletjrletrletjlrejtjtrlwjrejwlrjjreljtljelwjrtlwjtreljrlewjrlwjrlwejrlejltkdfsafd\",\"lat\":30.6880125,\"long\":-81.90594389,\"vip\":false}">>).
jd1(0, Fun) ->
?MODULE:Fun(?BodyBin1);
jd1(N, Fun) ->
?MODULE:Fun(?BodyBin1),
jd1(N - 1, Fun).
jd2(0, Fun) ->
?MODULE:Fun(?BodyBin2);
jd2(N, Fun) ->
?MODULE:Fun(?BodyBin2),
jd2(N - 1, Fun).
decode1(Bin) ->
jiffy:decode(Bin, [return_maps]).
decode2(Bin) ->
jiffy:decode(Bin, [return_maps, copy_strings]).
decode3(Bin) ->
jiffy:decode(Bin, [return_maps]).
decode4(Bin) ->
jiffy:decode(Bin, [return_maps, copy_strings]).

Laden…
Annuleren
Opslaan