couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [17/35] git commit: Support db names specified as a list
Date Fri, 01 Aug 2014 09:10:13 GMT
Support db names specified as a list

I was being a bit conservative before in gathering database names to
listen to. This keeps all binaries and converts lists to binaries.
Anything that's not a list or binary throws an error.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-event/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-event/commit/634658db
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-event/tree/634658db
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-event/diff/634658db

Branch: refs/heads/windsor-merge
Commit: 634658dbc56ee8babd98fc99543cb94026f0762f
Parents: b34d533
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Wed Apr 24 14:12:16 2013 -0500
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Jul 30 17:41:32 2014 +0100

----------------------------------------------------------------------
 src/couch_event_listener.erl | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-event/blob/634658db/src/couch_event_listener.erl
----------------------------------------------------------------------
diff --git a/src/couch_event_listener.erl b/src/couch_event_listener.erl
index 0eae00e..ca2bf29 100644
--- a/src/couch_event_listener.erl
+++ b/src/couch_event_listener.erl
@@ -219,11 +219,20 @@ get_all_dbnames(Options) ->
 get_all_dbnames([], []) ->
     erlang:error(no_dbnames_provided);
 get_all_dbnames([], Acc) ->
-    lists:usort(Acc);
-get_all_dbnames([{dbname, DbName} | Rest], Acc) when is_binary(DbName) ->
+    lists:usort(convert_dbname_list(Acc));
+get_all_dbnames([{dbname, DbName} | Rest], Acc) ->
     get_all_dbnames(Rest, [DbName | Acc]);
 get_all_dbnames([{dbnames, DbNames} | Rest], Acc) when is_list(DbNames) ->
-    BinDbNames = [DbName || DbName <- DbNames, is_binary(DbName)],
-    get_all_dbnames(Rest, BinDbNames ++ Acc);
+    get_all_dbnames(Rest, DbNames ++ Acc);
 get_all_dbnames([_Ignored | Rest], Acc) ->
     get_all_dbnames(Rest, Acc).
+
+
+convert_dbname_list([]) ->
+    [];
+convert_dbname_list([DbName | Rest]) when is_binary(DbName) ->
+    [DbName | convert_dbname_list(Rest)];
+convert_dbname_list([DbName | Rest]) when is_list(DbName) ->
+    [list_to_binary(DbName) | convert_dbname_list(Rest)];
+convert_dbname_list([DbName | _]) ->
+    erlang:error({invalid_dbname, DbName}).


Mime
View raw message