couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikewall...@apache.org
Subject [1/2] fabric commit: updated refs/heads/master to 3c204d0
Date Wed, 15 Jul 2015 10:20:26 GMT
Repository: couchdb-fabric
Updated Branches:
  refs/heads/master 405922c5d -> 3c204d009


Move is_*_db funs and helpers to fabric_util

This commit moves the is_*_db/1 funs and their helpers from
fabric_doc_update to fabric_util and exports them so they
can be re-used elsewhere in fabric.

COUCHDB-2738


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

Branch: refs/heads/master
Commit: c30665dcee9f5eeffc74ec03a5c7e50ed4d7c3b8
Parents: 405922c
Author: Mike Wallace <mikewallace@apache.org>
Authored: Wed Jul 15 10:50:21 2015 +0100
Committer: Mike Wallace <mikewallace@apache.org>
Committed: Wed Jul 15 10:53:36 2015 +0100

----------------------------------------------------------------------
 src/fabric_doc_update.erl | 20 ++------------------
 src/fabric_util.erl       | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/c30665dc/src/fabric_doc_update.erl
----------------------------------------------------------------------
diff --git a/src/fabric_doc_update.erl b/src/fabric_doc_update.erl
index a39efad..58bd355 100644
--- a/src/fabric_doc_update.erl
+++ b/src/fabric_doc_update.erl
@@ -99,8 +99,8 @@ handle_message({bad_request, Msg}, _, _) ->
     throw({bad_request, Msg}).
 
 before_doc_update(DbName, Docs, Opts) ->
-    Db = fake_db(Opts),
-    case {is_replicator_db(DbName), is_users_db(DbName)} of
+    Db = fabric_util:fake_db(Opts),
+    case {fabric_util:is_replicator_db(DbName), fabric_util:is_users_db(DbName)} of
         {true, _} ->
             [couch_replicator_manager:before_doc_update(Doc, Db) || Doc <- Docs];
         {_, true} ->
@@ -109,22 +109,6 @@ before_doc_update(DbName, Docs, Opts) ->
             Docs
     end.
 
-is_replicator_db(DbName) ->
-    ConfigName = list_to_binary(config:get("replicator", "db", "_replicator")),
-    DbName == ConfigName orelse path_ends_with(DbName, <<"_replicator">>).
-
-is_users_db(DbName) ->
-    ConfigName = list_to_binary(config:get(
-        "chttpd_auth", "authentication_db", "_users")),
-    DbName == ConfigName orelse path_ends_with(DbName, <<"_users">>).
-
-path_ends_with(Path, Suffix) ->
-    Suffix == couch_db:normalize_dbname(Path).
-
-fake_db(Opts) ->
-    UserCtx = couch_util:get_value(user_ctx, Opts, #user_ctx{}),
-    #db{user_ctx = UserCtx}.
-
 tag_docs([]) ->
     [];
 tag_docs([#doc{meta=Meta}=Doc | Rest]) ->

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/c30665dc/src/fabric_util.erl
----------------------------------------------------------------------
diff --git a/src/fabric_util.erl b/src/fabric_util.erl
index c5249d1..7b2ed75 100644
--- a/src/fabric_util.erl
+++ b/src/fabric_util.erl
@@ -18,6 +18,7 @@
 -export([request_timeout/0, attachments_timeout/0, all_docs_timeout/0]).
 -export([stream_start/2, stream_start/4]).
 -export([log_timeout/2, remove_done_workers/2]).
+-export([is_users_db/1, is_replicator_db/1, fake_db/1]).
 
 -compile({inline, [{doc_id_and_rev,1}]}).
 
@@ -281,6 +282,22 @@ remove_ancestors_test() ->
         remove_ancestors([kv(Bar2,1), kv(Bar1,1)], [])
     ).
 
+is_replicator_db(DbName) ->
+    ConfigName = list_to_binary(config:get("replicator", "db", "_replicator")),
+    DbName == ConfigName orelse path_ends_with(DbName, <<"_replicator">>).
+
+is_users_db(DbName) ->
+    ConfigName = list_to_binary(config:get(
+        "chttpd_auth", "authentication_db", "_users")),
+    DbName == ConfigName orelse path_ends_with(DbName, <<"_users">>).
+
+path_ends_with(Path, Suffix) ->
+    Suffix == couch_db:normalize_dbname(Path).
+
+fake_db(Opts) ->
+    UserCtx = couch_util:get_value(user_ctx, Opts, #user_ctx{}),
+    #db{user_ctx = UserCtx}.
+
 %% test function
 kv(Item, Count) ->
     {make_key(Item), {Item,Count}}.


Mime
View raw message