iilyak commented on a change in pull request #470: Scheduling Replicator
URL: https://github.com/apache/couchdb/pull/470#discussion_r111191220
##########
File path: src/couch_replicator/src/couch_replicator_utils.erl
##########
@@ -444,103 +75,79 @@ handle_db_event(DbName, compacted, Server) ->
handle_db_event(_DbName, _Event, Server) ->
{ok, Server}.
-% Obsolete - remove in next release
-sum_stats(S1, S2) ->
- couch_replicator_stats:sum_stats(S1, S2).
+rep_error_to_binary(Error) ->
+ couch_util:to_binary(error_reason(Error)).
+
+
+error_reason({shutdown, Error}) ->
+ error_reason(Error);
+error_reason({error, {Error, Reason}})
+ when is_atom(Error), is_binary(Reason) ->
+ io_lib:format("~s: ~s", [Error, Reason]);
+error_reason({error, Reason}) ->
+ Reason;
+error_reason(Reason) ->
+ Reason.
+
+
+get_json_value(Key, Props) ->
+ get_json_value(Key, Props, undefined).
+
+get_json_value(Key, Props, Default) when is_atom(Key) ->
+ Ref = make_ref(),
Review comment:
Very nice trick with `make_ref`. I had to stop and think what it actually
does. We can make it more clear using:
```
case value_if_key_exists(Key, Props) of
nil -> get_value(list_to_atom(?b2l(Key)), Props, Default);
Else -> Else
end
value_if_key_exists(Key, Props) ->
Ref = make_ref(),
case get_value(Key, Props, Ref) of
Ref -> nil;
Else -> Esle
end.
```
Feel free to ignore since it is cosmetic.
----------------------------------------------------------------
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