Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keygen-sh/statement_timeout
Wrap an Active Record transaction or query in a local statement timeout.
https://github.com/keygen-sh/statement_timeout
Last synced: 3 months ago
JSON representation
Wrap an Active Record transaction or query in a local statement timeout.
- Host: GitHub
- URL: https://github.com/keygen-sh/statement_timeout
- Owner: keygen-sh
- License: mit
- Created: 2024-05-29T16:58:47.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2024-08-14T13:28:26.000Z (3 months ago)
- Last Synced: 2024-08-15T14:05:33.234Z (3 months ago)
- Language: Ruby
- Size: 12.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# statement_timeout
[![CI](https://github.com/keygen-sh/statement_timeout/actions/workflows/test.yml/badge.svg)](https://github.com/keygen-sh/statement_timeout/actions)
[![Gem Version](https://badge.fury.io/rb/statement_timeout.svg)](https://badge.fury.io/rb/statement_timeout)Use `statement_timeout` to wrap an Active Record transaction or query in a
local statement timeout.This gem was extracted from [Keygen](https://keygen.sh).
Sponsored by:
_A fair source software licensing and distribution API._
## Installation
Add this line to your application's `Gemfile`:
```ruby
gem 'statement_timeout'
```And then execute:
```bash
$ bundle
```Or install it yourself as:
```bash
$ gem install statement_timeout
```## Usage
```ruby
User.statement_timeout 42.minutes do
some_expensive_operation
endUser.posts.statement_timeout 10.seconds do
some_cheap_operation
endPost.statement_timeout 10.minutes do |conn|
conn.transaction { archive_old_posts }
endTag.statement_timeout 6.hours do |conn|
conn.execute 'VACUUM ANALYZE tags'
end
```## Supported databases
We currently support PostgreSQL. We'd love contributions that add MySQL,
MariaDB, and SQLite support, but we probably won't add it ourselves.## Supported Rubies
**`statement_timeout` supports Ruby 3.1 and above.** We encourage you to upgrade
if you're on an older version. Ruby 3 provides a lot of great features, like
better pattern matching and a new shorthand hash syntax.## Is it any good?
Yes.
## Contributing
If you have an idea, or have discovered a bug, please open an issue or create a
pull request.## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).