Use the retry.lua module for retrying operations which are prone to periodic failure. For example: You can retry database operations, or network connections.
You should use retry for errors that indicate transitory problems which can be overcome with enough retries. However other errors can be more serious and may want to stop the interface instead. Fortunately using Iguana gives you complete control over identifying errors and implementing your desired response.
This page presents the Lua retry module by itself, so you can copy it directly into your project. However if you prefer to experiment with some sample code that uses the retry module then you should consider importing the Retry periodic failure channel from the Builtin: Iguana Tools repository.
Code for the retry.lua module [top]
Using retry.lua [top]
The module contains the
retry.call() function for retrying operations which might periodically fail like database operations.
How to use retry:
- Add it to your shared modules in any Translator project.
local retry = require 'retry'at the top of your script.
- Use the
retry.call()function to retry your operation.