retrycr
Version, currently 0.1.33 versions
- 0.1.3latestApr 13, 2021
- 0.1.1not indexedApr 13, 2021
- 0.1.0not indexedApr 13, 2021
github.com/taylorfinnell/retrycr
Retry blocks of Crystal code
12 stars
2 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
retrycr:
github: taylorfinnell/retrycr
version: ~> 0.1.3Then run:
shards installshard.yml
- Crystal
>= 0.24.2- License
- MIT
- Author
- Taylor Finnell
Dependencies
Development Dependencies
- ameba*github: veelenga/amebadev
README
retrycr
Retry blocks of Crystal code.
Installation
Add this to your application's shard.yml:
dependencies:
retrycr:
github: taylorfinnell/retrycr
Usage
require "retrycr"
Retry all exceptions.
retryable(tries: 1, wait: 1) do
# my code
end
You may specify which Exception classes trigger a retry.
retryable(on: ArgumentError | Base64::Error, tries: 1, wait: 1) do
# my code
end
The wait parameter can either be an Int32 or a Proc.
retryable(tries: 1, wait: ->(x : Int32) { 2**x }) do
# my code
end
The number of retries that have happened is yielded to the block.
retryable(tries: 1, wait: 1) do |retries|
puts "There have been #{retries} retries!"
end
You can specify a callback to run everytime the code is retried.
callback = -> (ex : Exeption) { "The code is about to be retried!" }
retryable(tries: 1, wait: 1, callback: callback) do |retries|
puts "There have been #{retries} retries!"
end
You can specify a callback to run after all retries are exhausted.
f = File.open("test")
callback = -> (retries : Int32) { f.close }
retryable(tries: 1, wait: 1, finally: callback) do |retries|
f.read
end
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.3- Tagged
- Apr 13, 2021
- Commit
e8c183370e8e- Crystal
>= 0.24.2- Indexed
- yes
Dependents
Repository
github.com/taylorfinnell/retrycr
Metadata
- Created
- Aug 12, 2026
- Updated
- Oct 15, 2026
- Synced
- Oct 15, 2026
- Versions
- 3