Retry periodic failure


This example shows how to use the retry.lua module to retry operations which might periodically fail. This is very useful to retry periodic failure for susceptible resources like databases and network connections.

Some errors will indicate transitory problems which can be overcome with enough retries. Other errors could indicate fatal conditions requiring the interface to stop. Iguana gives you complete control over identifying errors and implementing your desired response.

If you have any questions please contact us at

Using the Code [top]

  • Import the Retry periodic failure channel from the Builtin:¬†Iguana Tools repository
  • Experiment with the code to find out how it works
  • Then add the module(s) to your Translator project
  • Copy the require statement from the channel and add it at the top of your script
    Note: This module uses require to return a table containing a single function.
  • Adapt the code to your own requirements
  • Use the function to retry your operation
  • Interactive scripting help is included for this module

This is the github code for the main module in the From Translator component:

This is the github code for the main module in the To Translator component:

How it works [top]

The retry module is simple to use. The function retries the specified function call whenever an error occurs. The takes various arguments like: The function to be called, the number of retries, pause (in seconds) and zero or multiple arguments for the function, etc. Also multiple returns from the function are supported.

Our example uses an error function to handles errors returned. It also simulates fatal errors, non-fatal errors and success (no error).

Click to the execute script button a few times to see all these play out:

More information [top]

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.