https://github.com/hugoabonizio/timeout.cr
:hourglass_flowing_sand: Declarative timeout pattern for Crystal
https://github.com/hugoabonizio/timeout.cr
crystal
Last synced: 11 months ago
JSON representation
:hourglass_flowing_sand: Declarative timeout pattern for Crystal
- Host: GitHub
- URL: https://github.com/hugoabonizio/timeout.cr
- Owner: hugoabonizio
- License: mit
- Created: 2016-11-01T11:13:45.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-13T17:29:50.000Z (over 9 years ago)
- Last Synced: 2025-04-01T04:51:10.852Z (12 months ago)
- Topics: crystal
- Language: Crystal
- Size: 2.93 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Timeout.cr [](https://travis-ci.org/hugoabonizio/timeout.cr)
Declarative timeout pattern for Crystal using ```select``` keyword.
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
timeout:
github: hugoabonizio/timeout.cr
```
## Usage
```crystal
require "timeout"
ch = Channel(Int32).new
spawn do
sleep 2
ch.send 1
end
select
when value = ch.receive
puts "Done!"
when Timeout.after(1.second)
puts "Timeout!"
end
```
## Contributing
1. Fork it ( https://github.com/hugoabonizio/timeout.cr/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [hugoabonizio](https://github.com/hugoabonizio) Hugo Abonizio - creator, maintainer