Browse Source

arangoApi新增

erlArango_v1
SisMaker 5 years ago
parent
commit
83cc066b4b
2 changed files with 343 additions and 0 deletions
  1. +189
    -0
      src/arangoApi/agReplication.erl
  2. +154
    -0
      src/arangoApi/agTransactions.erl

+ 189
- 0
src/arangoApi/agReplication.erl View File

@ -0,0 +1,189 @@
-module(agReplication).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/3.6/http/replications.html
%
% ArangoDB数据库的当前设置的集合加上他们的指标使使
%
% GET /_api/replication/inventory
%
% includeSystemtrue
% _system默认值为false
% batchIdAPI调用的RocksDB引擎需要有效的batchId
% 使
% collection和state和 tick属性的JSON对象
%
%
%
%
% runningArangoDB 2.2true
% lastLogTick
% time
% lastLogTick值使lastLogTick的值
%
% / inventory API方法lastLogTick值以及集合和索引的数组
% / inventory返回的每个集合/ dump将集合数据流式传输到客户端lastLogTick的值 / inventory报告的集合上创建索引
%
% / logger-follow来获取在客户端调用/ inventory之后记录的第一批复制事件
% / logger-follow的调用应使用from参数/ inventory报告的lastLogTick的值 / logger-follow将返回 x-arango-replication-lastincluded
% / logger-follow以递增地获取上次传输后发生的新复制事件
% 使from参数 x-arango-replication-lastincluded头的值
% DBserver DBserver的IDDBserver
% global顶层对象使用参数包含一个键databases datbase名称
%
% 200
% 405使HTTP方法时返回
% 500500
getRepInventory(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/replication/inventory", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% POST /_api/replication/batch
%
% JSON对象是必需的
% ttl
% JSON对象
% ID
% JSON对象
% idID
% DBserver DBserver的IDDBserver
%
% 200
% 400ttl值无效DBserver属性或该属性非法
% 405使HTTP方法时返回
newRepBatch(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/replication/batch">>, [], BodyStr).
%
%
% DELETE /_api/replication/batch/{id}
%
%
% idID
%
% DBserver DBserver的IDDBserver
%
% 204
% 400
% 405使HTTP方法时返回
delRepBatch(PoolNameOrSocket, BatchId) ->
Path = <<"/_api/replication/batch/", (agMiscUtils:toBinary(BatchId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], undefined).
%
% PUT /_api/replication/batch/{id}
%
%
% idID
% JSON对象是必需的
% ttl
% 使ID和提供的ttl值来扩展现有转储批次的ttl
% ttl
% DBserver DBserver的IDDBserver
%
% 204ttl
% 400ttl值无效或未找到批次
% 405使HTTP方法时返回
% dump命令的结果可能非常庞大dump可能不会一次返回集合中的所有数据dump命令dump命令不仅会返回集合中的当前文档
% dump方法将仅返回文档
% 使
prolongRepBatch(PoolNameOrSocket, BatchId, MapData) ->
Path = <<"/_api/replication/batch/", (agMiscUtils:toBinary(BatchId))/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr).
%
% GET /_api/replication/dump
%
% ID
% chunkSize
% batchIdrocksdb-使ID
% frommmfiles-
% mmfiles-
% includeSystemmmfiles-true
% ticksmmfiles-tick值true
% mmfiles-WALtrue
%
% 使from查询参数使from参数时from值的集合条目from的日志条目将被排除
% 使
% CHUNKSIZE查询参数可用于控制结果的大小CHUNKSIZE值也仅是被兑现chunkSize值太低可能导致服务器无法仅将一个条目放入结果中并返回它chunkSize值 chunkSizechunkSize
% chunkSize使
% Content-Type是application / x-arango-dump
% JSON对象
% ticktick属性
% key/使
% rev/ID
% data23002301//
% type
% 2300/
% 2301/
% 2302/
%
%
% 200 x-arango-replication-lastincluded设置为最后返回的文档的刻度
% 204x-arango-replication-lastincluded是0
% 400from或to值无效
% 404
% 405使HTTP方法时返回
% 500500
getRepDump(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/replication/dump", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
%
% PUT /_api/replication/sync
% JSON对象是必需的
% tcp//192.168.173.138529
% database
% username使ArangoDB用户名
% password使
% includeSystem
% true使false
% strictTypeinclude或exclude
% restrictCollections使 restrictTypelimitType为includelimitType为exclude
% initialSyncMaxWaitTime0
% ArangoDB数据库的完整数据同步
% 使ArangoDB数据库连接到远程端点ArangoDB数据库上创建数据状态的本地备份
% sync首先会从远程端点获取集合和索引的列表 API来实现ArangoDB数据库中的数据ArangoDB数据库 API
% JSON对象
%
% lastLogTick使
% ArangoDB数据库
% 使
%
%
% 200
% 400
% 405使HTTP方法时返回
% 500
% 501
startRepSync(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/sync">>, [], BodyStr).
%
%
% GET /_api/replication/clusterInventory
%
% includeSystemtrue
%
% JSON对象数组// {DB-} / * arangodump的数据格式
%
% 200
% 405使HTTP方法时返回
% 500500
getRepClusterInventory(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/replication/clusterInventory", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).

+ 154
- 0
src/arangoApi/agTransactions.erl View File

@ -5,3 +5,157 @@
% doc_address:https://www.arangodb.com/docs/stable/http/transaction.html
% HTTP接口
%
%
%
% 10
% 128 MB
%
%
% 使
%
%
% POST /_api/transaction/begin
% JSON对象是必需的
% collectionscollections必须是一个JSON对象readwrite或Exclusive collection名称的数组或单个collection name作为字符串使write或Exclusive属性声明将在事务中写入的集合allowImplicit设置为false 使
% waitForSync
% allowImplicit
% lockTimeout使lockTimeout设置为0将使ArangoDB不会在等待锁定时超时
% maxTransactionSizeRocksDB存储引擎的尊敬
% POST请求的正文中传递HTTP 201
% JSON对象具有以下属性
% codeHTTP状态码
%
% id
% status running
% 使HTTP 400HTTP 404
% JSON对象
% errortrue
% codeHTTP状态码
% errorNum
% errorMessage
beginTransaction(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/transaction/begin">>, [], BodyStr).
%
%
% GET /_api/transaction/{transaction-id}
%
% transaction-id
%
% id
% status
%
% 200 HTTP 200
% 400使HTTP 400
% 404使HTTP 404
getTransactionStatus(PoolNameOrSocket, TransactionId) ->
Path = <<"/_api/transaction/", (agMiscUtils:toBinary(TransactionId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% PUT /_api/transaction/{transaction-id}
%
% transaction-id
%
% HTTP 200JSON对象具有以下属性
% error false
% codeHTTP状态码
%
% id
% status committed
% 使HTTP 400HTTP 404HTTP 409
% JSON对象
% errortrue
% codeHTTP状态码
% errorNum
% errorMessage
%
% 200 HTTP 200
% 400使HTTP 400
% 404使HTTP 404
% 409使HTTP 409
commitTransaction(PoolNameOrSocket, TransactionId) ->
Path = <<"/_api/transaction/", (agMiscUtils:toBinary(TransactionId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined).
%
% DELETE /_api/transaction/{transaction-id}
%
% transaction-id
%
% HTTP 200JSON对象具有以下属性
% error false
% codeHTTP状态码
%
% id
% status aborted
% 使HTTP 400HTTP 404HTTP 409
% JSON对象
% errortrue
% codeHTTP状态码
% errorNum
% errorMessage
%
% 200 HTTP 200
% 400使HTTP 400
% 404使HTTP 404
% 409HTTP 409
abortTransaction(PoolNameOrSocket, TransactionId) ->
Path = <<"/_api/transaction/", (agMiscUtils:toBinary(TransactionId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
%
% GET /_api/transaction
% 使transactions属性进行描述
%
% idID
% status
%
% 200HTTP 200
getTransactionList(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/transaction">>, [], undefined).
% JavaScript交易的HTTP接口
% ArangoDB的JS事务在服务器上执行
% ArangoDB中的JS事务不提供单独的BEGINCOMMIT和ROLLBACK ArangoDB JS事务由JavaScript函数描述JavaScript函数中的代码将以事务方式执行
%
%
% POST /_api/transaction
% JSON对象是必需的
% collectionscollections必须是一个JSON对象readwrite或Exclusive collection名称的数组或单个collection name作为字符串使write或Exclusive属性声明将在事务中写入的集合allowImplicit设置为false 使
% actionJavaScript代码的形式 return语句结尾 REST API还将在result属性中返回返回的值
% waitForSync
% allowImplicit
% lockTimeout使lockTimeout设置为0将使ArangoDB不会在等待锁定时超时
%
% maxTransactionSizeRocksDB存储引擎的尊敬
% POST请求的正文中传递
% HTTP 200result属性中返回
% JSON对象具有以下属性
% error false
% codeHTTP状态码
%
% 使HTTP 400
% JSON对象
% errortrue
% codeHTTP状态码
% errorNum
% errorMessage
% 使 HTTP 400HTTP 409HTTP 500
%
% 200 HTTP 200
% 400使HTTP 400
% 404使HTTP 404
% 500使HTTP 500
executeTransaction(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/transaction">>, [], BodyStr).

Loading…
Cancel
Save