couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject mem3 commit: updated refs/heads/master to 3f229b2
Date Mon, 26 Jan 2015 10:58:08 GMT
Repository: couchdb-mem3
Updated Branches:
  refs/heads/master 04345bd03 -> 3f229b278


Use ADMIN_CTX macro from couch_db.hrl


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/commit/3f229b27
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/tree/3f229b27
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/diff/3f229b27

Branch: refs/heads/master
Commit: 3f229b2789587babc8d14db9cf79ad534dac257d
Parents: 04345bd
Author: Alexander Shorin <kxepal@apache.org>
Authored: Mon Jan 26 07:29:37 2015 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Mon Jan 26 07:29:37 2015 +0300

----------------------------------------------------------------------
 src/mem3_rep.erl    | 10 +++-------
 src/mem3_rpc.erl    |  9 +++------
 src/mem3_shards.erl |  3 +--
 src/mem3_util.erl   |  5 ++---
 4 files changed, 9 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/3f229b27/src/mem3_rep.erl
----------------------------------------------------------------------
diff --git a/src/mem3_rep.erl b/src/mem3_rep.erl
index 1213884..6d32b1b 100644
--- a/src/mem3_rep.erl
+++ b/src/mem3_rep.erl
@@ -28,10 +28,6 @@
 -include_lib("mem3/include/mem3.hrl").
 -include_lib("couch/include/couch_db.hrl").
 
-
--define(CTX, #user_ctx{roles = [<<"_admin">>]}).
-
-
 -record(acc, {
     batch_size,
     batch_count,
@@ -78,7 +74,7 @@ go(#shard{} = Source, #shard{} = Target, Opts) ->
 
 
 go(#acc{source=Source, batch_count=BC}=Acc0) ->
-    case couch_db:open(Source#shard.name, [{user_ctx,?CTX}]) of
+    case couch_db:open(Source#shard.name, [?ADMIN_CTX]) of
     {ok, Db} ->
         Acc = Acc0#acc{db=Db},
         Resp = try
@@ -271,7 +267,7 @@ find_missing_revs(Acc) ->
     end, Infos),
     mem3_rpc:get_missing_revs(Node, Name, IdsRevs, [
         {io_priority, {internal_repl, Name}},
-        {user_ctx, ?CTX}
+        ?ADMIN_CTX
     ]).
 
 
@@ -290,7 +286,7 @@ save_on_target(Node, Name, Docs) ->
     mem3_rpc:update_docs(Node, Name, Docs, [
         replicated_changes,
         full_commit,
-        {user_ctx, ?CTX},
+        ?ADMIN_CTX,
         {io_priority, {internal_repl, Name}}
     ]),
     ok.

http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/3f229b27/src/mem3_rpc.erl
----------------------------------------------------------------------
diff --git a/src/mem3_rpc.erl b/src/mem3_rpc.erl
index 9507f5b..c7952b9 100644
--- a/src/mem3_rpc.erl
+++ b/src/mem3_rpc.erl
@@ -35,9 +35,6 @@
 -include_lib("couch/include/couch_db.hrl").
 
 
--define(CTX, #user_ctx{roles = [<<"_admin">>]}).
-
-
 get_missing_revs(Node, DbName, IdsRevs, Options) ->
     rexi_call(Node, {fabric_rpc, get_missing_revs, [DbName, IdsRevs, Options]}).
 
@@ -63,7 +60,7 @@ find_common_seq(Node, DbName, SourceUUID, SourceEpochs) ->
 
 load_checkpoint_rpc(DbName, SourceNode, SourceUUID) ->
     erlang:put(io_priority, {internal_repl, DbName}),
-    case couch_db:open_int(DbName, [{user_ctx, ?CTX}]) of
+    case couch_db:open_int(DbName, [?ADMIN_CTX]) of
     {ok, Db} ->
         TargetUUID = couch_db:get_uuid(Db),
         NewId = mem3_rep:make_local_id(SourceUUID, TargetUUID),
@@ -86,7 +83,7 @@ load_checkpoint_rpc(DbName, SourceNode, SourceUUID) ->
 
 save_checkpoint_rpc(DbName, Id, SourceSeq, NewEntry0, History0) ->
     erlang:put(io_priority, {internal_repl, DbName}),
-    case couch_db:open_int(DbName, [{user_ctx, ?CTX}]) of
+    case couch_db:open_int(DbName, [?ADMIN_CTX]) of
         {ok, #db{update_seq = TargetSeq} = Db} ->
             NewEntry = {[
                 {<<"target_node">>, atom_to_binary(node(), utf8)},
@@ -116,7 +113,7 @@ save_checkpoint_rpc(DbName, Id, SourceSeq, NewEntry0, History0) ->
 
 find_common_seq_rpc(DbName, SourceUUID, SourceEpochs) ->
     erlang:put(io_priority, {internal_repl, DbName}),
-    case couch_db:open_int(DbName, [{user_ctx, ?CTX}]) of
+    case couch_db:open_int(DbName, [?ADMIN_CTX]) of
     {ok, Db} ->
         case couch_db:get_uuid(Db) of
         SourceUUID ->

http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/3f229b27/src/mem3_shards.erl
----------------------------------------------------------------------
diff --git a/src/mem3_shards.erl b/src/mem3_shards.erl
index cd15a87..7583db9 100644
--- a/src/mem3_shards.erl
+++ b/src/mem3_shards.erl
@@ -297,8 +297,7 @@ create_if_missing(Name) ->
     true ->
         ok;
     false ->
-        Options = [{user_ctx, #user_ctx{roles=[<<"_admin">>]}}],
-        case couch_server:create(Name, Options) of
+        case couch_server:create(Name, [?ADMIN_CTX]) of
         {ok, Db} ->
             couch_db:close(Db);
         Error ->

http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/3f229b27/src/mem3_util.erl
----------------------------------------------------------------------
diff --git a/src/mem3_util.erl b/src/mem3_util.erl
index c437d52..e19bf33 100644
--- a/src/mem3_util.erl
+++ b/src/mem3_util.erl
@@ -214,12 +214,11 @@ shard_info(DbName) ->
 ensure_exists(DbName) when is_list(DbName) ->
     ensure_exists(list_to_binary(DbName));
 ensure_exists(DbName) ->
-    Options = [{user_ctx, #user_ctx{roles=[<<"_admin">>]}}],
-    case couch_db:open(DbName, [nologifmissing, sys_db | Options]) of
+    case couch_db:open(DbName, [nologifmissing, sys_db | [?ADMIN_CTX]]) of
     {ok, Db} ->
         {ok, Db};
     _ ->
-        couch_server:create(DbName, Options)
+        couch_server:create(DbName, [?ADMIN_CTX])
     end.
 
 


Mime
View raw message