lua-aws
lua-aws copied to clipboard
retry API call
suggested by @nkzawa, and I'm +1 on this.
motivation
- API call not always success, due to various reason. and simply retry API call until success (with some limit) can be good solution for this.
- if retry duration based on exponential backoff, configuration should be like following:
-- if omitted, proper default value is set
{
max_retry: number,
jitter: {
lower: number,
upper: number
},
initial_backoff: number
}
- and can be speficied like following
-- as default config to AWS.new
local aws = AWS.new({
accessKeyId = os.getenv('AWS_ACCESS_KEY'),
secretAccessKey = os.getenv('AWS_SECRET_KEY'),
retry = { ... above configuration }
})
-- or as per call configuration of each API, as its 2nd argument
-- (need breaking change for the 2nd argument specification, because it currently used to provide response object, which contains file handle to write response directly, see s3 test getObject to file for example)
aws.EC2:api():describeInstances({}, {
retry = { ... above configuration }
})