Guest User

Untitled

a guest
Jan 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. require "rubygems"
  2. require "bundler/setup" #using bundler for dependencies
  3. #echo_with_ar.rb
  4. require 'goliath'
  5. require 'active_record'
  6.  
  7. class User < ActiveRecord::Base
  8. end
  9.  
  10.  
  11. class EchoWithAr < Goliath::API
  12. use Goliath::Rack::Params
  13. use Goliath::Rack::DefaultMimeType
  14. use Goliath::Rack::Render, 'json'
  15.  
  16. def response(env)
  17. #user = User.find(1).to_json
  18. User.connection.execute("SELECT sleep(1.0)")
  19. ActiveRecord::Base.clear_active_connections!
  20. [200, {}, "slept"]
  21. end
  22. end
  23.  
  24. #config/echo_with_ar.rb
  25. require 'em-synchrony/activerecord'
  26.  
  27. ActiveRecord::Base.establish_connection(:adapter => 'em_mysql2',
  28. :database => 'goliath_app',
  29. :username => 'root',
  30. :password => '',
  31. :reconnect => true,
  32. :pool => 10,
  33. :wait_timeout => 0.5,
  34. :host => 'localhost')
Add Comment
Please, Sign In to add comment