Uploaded image for project: 'Couchbase Documentation'
  1. Couchbase Documentation
  2. DOC-5012

Document retrying after errors

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Major
    • None
    • Mad Hatter
    • eventing

    Description

      If a function call (such as curl) fails in JS handler, one may wish to retry the operation later. Below example illustrates it. Please include in documentation:

      // Main function
      function doSomething(params) {
         // do work using curl etc
         ...
      }
       
      // Helper function to retry
      function retryAfter2Hours(fn, params) {
        var retryTime = new Date();
        retryTime.setHours(retryTime.getHours() + 2);
        createTimer(fn, retryTime, id, params);
      }
       
      // Example of retrying if something goes wrong
      var ok = doSomething(params);
      if (!ok) {
          retryAfter2Hours(doSomething, params);
      }
       
      // Example of retrying if exception is thrown
      try {
          doSomething(params);
      } catch (err) {
          retryAfter2Hours(doSomething, params);
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            amarantha.kulkarni Amarantha Kulkarni (Inactive)
            siri Sriram Melkote (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty