Github user sagelywizard commented on a diff in the pull request:

    
https://github.com/apache/couchdb-couch-replicator/pull/40#discussion_r66886678
  
    --- Diff: src/couch_replicator_httpc.erl ---
    @@ -251,16 +258,41 @@ clean_mailbox(_, Count) when Count > 0 ->
     maybe_retry(Error, Worker, #httpdb{retries = 0} = HttpDb, Params) ->
         report_error(Worker, HttpDb, Params, {error, Error});
     
    +%% For 429 errors, we perform an exponential backoff up to 250 * 2^15
    +%% times, or roughly 2.17 hours. Since the #httpd.retries is initialized
    +%% to 10 and we need 15, we use the Wait time as a timeout/failure end.
    +maybe_retry(backoff, Worker, #httpdb{wait = Wait} = HttpDb, Params) ->
    +    ok = timer:sleep(random:uniform(Wait)),
    +    Wait2 = Wait*2,
    --- End diff --
    
    A cleaner way to write this would be:
    
    ```
    case Wait*2 of
        Wait2 when Wait2 >= ?MAX_BACKOFF_LOG_THRESHOLD -> % comment
            stuff;
        Wait2 when Wait2 > ?MAX_BACKOFF_WAIT ->
            other_stuff;
        Wait2 ->
            final_stuff
    end
    ```
    Just my two cents.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to