You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ei...@apache.org on 2020/05/14 12:42:17 UTC

[couchdb] branch aegis_db_info created (now 96d3524)

This is an automated email from the ASF dual-hosted git repository.

eiri pushed a change to branch aegis_db_info
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 96d3524  Add aegis info to db_info

This branch includes the following new commits:

     new 96d3524  Add aegis info to db_info

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Add aegis info to db_info

Posted by ei...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

eiri pushed a commit to branch aegis_db_info
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 96d3524762207edf09104563c5c2abdb3320189c
Author: Eric Avdey <ei...@eiri.ca>
AuthorDate: Thu May 14 09:41:08 2020 -0300

    Add aegis info to db_info
---
 src/aegis/src/aegis.erl                  |  5 +++++
 src/aegis/src/aegis_key_manager.erl      |  3 +++
 src/aegis/src/aegis_noop_key_manager.erl |  7 ++++++-
 src/fabric/src/fabric2_fdb.erl           | 13 ++++++++++---
 4 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/aegis/src/aegis.erl b/src/aegis/src/aegis.erl
index e8a0b4b..c158c25 100644
--- a/src/aegis/src/aegis.erl
+++ b/src/aegis/src/aegis.erl
@@ -20,6 +20,7 @@
 -export([
     init_db/2,
     open_db/1,
+    get_db_info/1,
 
     decrypt/2,
     decrypt/3,
@@ -39,6 +40,10 @@ open_db(#{} = Db) ->
     }.
 
 
+get_db_info(#{} = Db) ->
+    ?AEGIS_KEY_MANAGER:get_db_info(Db).
+
+
 encrypt(#{} = _Db, _Key, <<>>) ->
     <<>>;
 
diff --git a/src/aegis/src/aegis_key_manager.erl b/src/aegis/src/aegis_key_manager.erl
index aa9e342..cc21493 100644
--- a/src/aegis/src/aegis_key_manager.erl
+++ b/src/aegis/src/aegis_key_manager.erl
@@ -20,3 +20,6 @@
 
 
 -callback open_db(Db :: #{}) -> {ok, binary()} | false.
+
+
+-callback get_db_info(Db :: #{}) -> list().
diff --git a/src/aegis/src/aegis_noop_key_manager.erl b/src/aegis/src/aegis_noop_key_manager.erl
index 2b61f1d..795fafe 100644
--- a/src/aegis/src/aegis_noop_key_manager.erl
+++ b/src/aegis/src/aegis_noop_key_manager.erl
@@ -18,7 +18,8 @@
 
 -export([
     init_db/2,
-    open_db/1
+    open_db/1,
+    get_db_info/1
 ]).
 
 
@@ -29,3 +30,7 @@ init_db(#{} = _Db, _Options) ->
 
 open_db(#{} = _Db) ->
     false.
+
+
+get_db_info(#{} = _Db) ->
+    [{encrypted, false}].
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index 8264e8a..970f78b 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -105,6 +105,7 @@
     db_prefix,
     changes_future,
     meta_future,
+    aegis_future,
     retries = 0
 }).
 
@@ -499,6 +500,8 @@ get_info_future(Tx, DbPrefix) ->
     StatsPrefix = erlfdb_tuple:pack({?DB_STATS}, DbPrefix),
     MetaFuture = erlfdb:get_range_startswith(Tx, StatsPrefix),
 
+    AegisFuture = aegis:get_db_info(#{tx => Tx, db_prefix => DbPrefix}),
+
     % Save the tx object only if it's read-only as we might retry to get the
     % future again after the tx was reset
     SaveTx = case erlfdb:get_writes_allowed(Tx) of
@@ -510,7 +513,8 @@ get_info_future(Tx, DbPrefix) ->
         tx = SaveTx,
         db_prefix = DbPrefix,
         changes_future = ChangesFuture,
-        meta_future = MetaFuture
+        meta_future = MetaFuture,
+        aegis_future = AegisFuture
     }.
 
 
@@ -1998,7 +2002,8 @@ get_info_wait_int(#info_future{} = InfoFuture) ->
     #info_future{
         db_prefix = DbPrefix,
         changes_future = ChangesFuture,
-        meta_future = MetaFuture
+        meta_future = MetaFuture,
+        aegis_future = AegisFuture
     } = InfoFuture,
 
     RawSeq = case erlfdb:wait(ChangesFuture) of
@@ -2010,6 +2015,8 @@ get_info_wait_int(#info_future{} = InfoFuture) ->
     end,
     CProp = {update_seq, RawSeq},
 
+    AProps = erlfdb:wait(AegisFuture),
+
     MProps = lists:foldl(fun({K, V}, Acc) ->
         case erlfdb_tuple:unpack(K, DbPrefix) of
             {?DB_STATS, <<"doc_count">>} ->
@@ -2026,7 +2033,7 @@ get_info_wait_int(#info_future{} = InfoFuture) ->
         end
     end, [{sizes, {[]}}], erlfdb:wait(MetaFuture)),
 
-    [CProp | MProps].
+    lists:append(AProps, [CProp | MProps]).
 
 
 binary_chunk_size() ->