nickva commented on a change in pull request #470: Scheduling Replicator
URL: https://github.com/apache/couchdb/pull/470#discussion_r111028690
##########
File path: src/chttpd/src/chttpd_misc.erl
##########
@@ -439,3 +500,67 @@ message_queues(Registered) ->
{Type, Length} = process_info(whereis(Name), Type),
{Name, Length}
end, Registered).
+
+stream_doc_info_cb(Info, Acc) ->
+ #rep_docs_acc{
+ resp = Resp,
+ prepend = Pre,
+ count = Count,
+ skip = Skip,
+ limit = Limit
+ } = Acc,
+ case Count >= Skip andalso Count < (Skip + Limit) of
+ true ->
+ Chunk = [Pre, ?JSON_ENCODE(update_db_name(Info))],
+ {ok, Resp1} = chttpd:send_delayed_chunk(Resp, Chunk),
+ Acc#rep_docs_acc{resp = Resp1, prepend = ",\r\n", count = Count + 1};
+ false ->
+ Acc#rep_docs_acc{count = Count + 1}
+ end.
+
+update_db_name({Props}) ->
+ {value, {database, DbName}, Props1} = lists:keytake(database, 1, Props),
+ {[{database, normalize_db_name(DbName)} | Props1]}.
+
+normalize_db_name(<<"shards/", _/binary>> = DbName) ->
+ mem3:dbname(DbName);
+normalize_db_name(DbName) ->
+ DbName.
+
+parse_replication_state_filter(undefined) ->
+ []; % This is the default (wildcard) filter
+parse_replication_state_filter(States) when is_list(States) ->
+ AllStates = couch_replicator:replication_states(),
+ StrStates = [string:to_lower(S) || S <- string:tokens(States, ",")],
+ AtomStates = try
+ [list_to_existing_atom(S) || S <- StrStates]
Review comment:
What's the concern though? list_to_existing_atom is specifically used first
in order to validate the input. It's designed to crash quicker before we even
get to build sets and such from input strings.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services