Project

cant_wait

0.0
No release in over 3 years
Low commit activity in last 3 years
Provides statement timeouts for PostgreSQL and PostGIS databases in a Ruby on Rails web application. Stops any SQL statement that takes more than a specified number of milliseconds.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.0.3
 Project Readme

cant_wait

Gem Version Dependency Status Code Climate Build Status

This Ruby gem adds statement timeouts for PostgreSQL and PostGIS databases within a Ruby on Rails web application.

From the PostgreSQL documentation:

statement_timeout (integer)

     Abort any statement that takes more than the specified number of milliseconds, starting
     from the time the command arrives at the server from the client. If log_min_error_statement
     is set to ERROR or lower, the statement that timed out will also be logged.  A value of zero
     (the default) turns this off.

     Setting statement_timeout in postgresql.conf is not recommended because it would affect all
     sessions.

(© 1996-2013 The PostgreSQL Global Development Group)

(Visit http://www.postgresql.org/docs/devel/static/runtime-config-client.html for more information)

If any SQL statement takes more time than the timeout value (measured in milliseconds), its execution will be cancelled, and Active Record would raise an exception.

ActiveRecord::StatementInvalid: PGError: ERROR:  canceling statement due to statement timeout

Installation

Add this line to your application's Gemfile:

gem 'cant_wait', '~> 1.1.1'

And then execute:

bundle

Usage

In the file config/database.yml of the Rails application, indicate a timeout in milliseconds for each environment:

production:
  adapter: postgresql
  timeout: 180_000  # 3 minutes
  ...

or, in the case of PostGIS:

production:
  adapter: postgis
  timeout: 180_000  # 3 minutes
  ...

Then restart the application to establish the new database settings.

Dependencies

The minimum requirement is Rails 3.0.3 and ruby. The gem has been tested with Rails 3.0.3 and above (including versions 4.0.0 and 4.0.1). Previous versions of Rails are not compatible with the present version of bundler.

The minimum version of ruby is MRI 1.9.1 or compatible, as the gem uses 1.9 syntax.

It has also been tested with PostgreSQL versions 8 and 9, but it may work also in other versions supported by Active Record (see PostgreSQL documentation).

It has also been tested using PostGIS 2.1, but other versions supported by the activerecord-postgis-adapter should work as well.

Supported Rubies

cant_wait has been tested with the following versions of Ruby:

  • 1.9.2
  • 1.9.3
  • 2.0.0
  • jruby

The gem may work fine with other Ruby flavors/versions not listed above.

See the development documentation below for more details.

Signature

All the versions of cant_wait released from rubygems.org have been digitally signed.

To verify that the gem has not been tampered with, I am providing the certificate used in its repository, at Github.

Development

If you find any problem, please feel free to open an issue at the gem's repository (GitHub).

These files could be of particular interest:

License

cant_wait is released under the MIT License.

November 2013