Last active
October 11, 2015 03:07
-
-
Save qerub/3793354 to your computer and use it in GitHub Desktop.
Rack middleware that makes sure requests don't get a dead Sequel connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "sequel/extensions/connection_validator" | |
# https://github.com/jeremyevans/sequel/blob/master/lib/sequel/extensions/connection_validator.rb | |
module Rack | |
class SequelConnectionValidator | |
def initialize(app, db) | |
@app = app | |
@db = db | |
@db.extension(:connection_validator) | |
@db.pool.connection_validation_timeout = -1 | |
end | |
def call(env) | |
@db.synchronize do | |
@app.call(env) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment