Code Monkey home page Code Monkey logo

cant_wait's Introduction

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

cant_wait's People

Contributors

carloscd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

stsci-opo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.