|
|
@ -1,39 +1,41 @@ |
|
|
|
# erlArango |
|
|
|
arangodb多模数据库erlang驱动程序 |
|
|
|
arangodb erlang driver |
|
|
|
erlang otp21.2+ arangodb 3.6.2 3.7 |
|
|
|
|
|
|
|
## 特点 |
|
|
|
高效,快速,简单易用。 |
|
|
|
1. 为了该驱动尽可能的高效,定制化封装了一个带连接池的http1.1的客户端(agHttpCli) |
|
|
|
封装的agHttpCli与同类http客户端测试对比可参考:https://github.com/SisMaker/httpc_bench |
|
|
|
2. 为了更加快速的decode和encode json数据,json库引入了jiffy,经过测试jiffy效率还是很不错的。 |
|
|
|
3. 该驱动可以使用连接池,也可以仅仅在单进程(非连接池模式)建立多个连接进行各种数据操作。使用连接池时支持同步与异步操作,如果要使用异步操作需要额外保存requestId |
|
|
|
等待接收数据返回,当前改驱动封装的API均使用同步操作,如果需要异步操作可自行修改。单进程操作时仅支持同步操作。 |
|
|
|
单进程模式下相对连接池模式可以减少一次数据在进程间的复制,对于大量数据的操作,可以考虑在数据管理进程单独建立数据库连接,而不用连接池。 |
|
|
|
4. 连接池模式和非连接池模式API接口保证了同一性,不用区别对待, 易于理解和连接池模式和非连接池模式相互转换修改。 |
|
|
|
# Feature |
|
|
|
Efficient, fast and easy to use. |
|
|
|
1. To make this driver as efficient as possible, customizations encapsulate an HTTP1.1 client(agHttpCli) with connection pooling. |
|
|
|
Comparisons between packaged agHttpCli 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. |
|
|
|
|
|
|
|
## 暂不支持批处理请求 |
|
|
|
# Batch requests are not supported |
|
|
|
https://www.arangodb.com/docs/stable/http/batch-request.html |
|
|
|
|
|
|
|
## 编译 |
|
|
|
|
|
|
|
# compile |
|
|
|
rebar get-deps; rebar compile or rebar3 compile |
|
|
|
注意:在windows平台编译jiffy,需要额外搭建相关编译环境,具体可参见:https://github.com/SisMaker/erlUtils/tree/master/src/docs |
|
|
|
|
|
|
|
## 使用 |
|
|
|
rebar: erl -pa ./ebin -pa ./deps/jiffy/ebin |
|
|
|
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) |
|
|
|
|
|
|
|
# how to use |
|
|
|
rebar: erl -pa ./ebin -pa ./deps/jiffy/ebin or |
|
|
|
revar3: rebar3 shell |
|
|
|
非连接池模式 |
|
|
|
先建立连接 |
|
|
|
{ok, S} = agHttpCli:connect([]). %% 使用默认的配置 |
|
|
|
然后就可以使用S作为第一个参数调用各种API了 |
|
|
|
Non-connection pooling mode |
|
|
|
Make a connection first |
|
|
|
{ok, Socket} = agHttpCli:connect([]). %% Use default Settings |
|
|
|
Then you can then call various apis using Socket as the first argument |
|
|
|
agMgrDb:curDbInfo(S). |
|
|
|
|
|
|
|
连接池模式 |
|
|
|
application:ensure_all_started(erlArango). %%启动app |
|
|
|
agHttpCli:startPool(poolName, [], []). %%初始连接池 |
|
|
|
然后就可以使用poolName作为第一个参数调用各种API了 |
|
|
|
Connection pooling mode |
|
|
|
application:ensure_all_started(erlArango). %% start app |
|
|
|
agHttpCli:startPool(poolName, [], []). %% start pool |
|
|
|
Then you can then invoke various apis using poolName as the first argument |
|
|
|
agMgrDb:curDbInfo(poolName). |
|
|
|
|
|
|
|
## TODO |
|
|
|
将注释转为edoc格式 |
|
|
|
|
|
|
|
|