genretry: simple exponential backoff in elixir
TRANSCRIPT
GenRetryif at first you don't succeed
pete gamache // ElixirConf 2016 // @gamache
TL;DR
• GenRetry provides retry with exponential backoff for any function that raises an exception when it fails
• Use it, it's easy
• https://github.com/appcues/gen_retry
• Your code is perfectWorks first time, every time
• I am not you
(my code)
J/K, your code fails too
• Failures happen
• Minimizing failures is nice
• Handling failures is even nicer
• Primary weapon: repetition
Exponential Backoff
• Set an initial retry delay
• Every time you retry, double the previous delay
• Examples are everywhere
• Optional: jitter adds a random percentage of delay
GenRetry basics
• GenRetry.retry/2 handles background processes where we don't care about the output -- replaces spawn_link
• GenRetry.Task.async/2 handles future/promise-style tasks where we do care about the output --> replaces Task.async
Background Process
GenRetry.retry
Task.async
GenRetry.Task.async
In conclusion
• Let it crash -- on your terms
• Check out our other tools! https://github.com/appcues/
Thanks!