advanced_connection 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +8 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +63 -0
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +218 -0
  8. data/MIT-LICENSE +20 -0
  9. data/README.rdoc +3 -0
  10. data/Rakefile +165 -0
  11. data/advanced_connection.gemspec +49 -0
  12. data/gemfiles/jruby/rails4_1.gemfile +7 -0
  13. data/gemfiles/jruby/rails4_2.gemfile +7 -0
  14. data/gemfiles/ruby/rails4_1.gemfile +7 -0
  15. data/gemfiles/ruby/rails4_2.gemfile +7 -0
  16. data/lib/advanced_connection/active_record_ext/abstract_adapter/statement_pooling.rb +121 -0
  17. data/lib/advanced_connection/active_record_ext/abstract_adapter.rb +48 -0
  18. data/lib/advanced_connection/active_record_ext/connection_pool/idle_manager.rb +271 -0
  19. data/lib/advanced_connection/active_record_ext/connection_pool/queues.rb +60 -0
  20. data/lib/advanced_connection/active_record_ext/connection_pool/statement_pooling.rb +42 -0
  21. data/lib/advanced_connection/active_record_ext/connection_pool/without_connection.rb +93 -0
  22. data/lib/advanced_connection/active_record_ext/connection_pool.rb +38 -0
  23. data/lib/advanced_connection/active_record_ext/without_connection.rb +30 -0
  24. data/lib/advanced_connection/active_record_ext.rb +59 -0
  25. data/lib/advanced_connection/config.rb +247 -0
  26. data/lib/advanced_connection/error.rb +27 -0
  27. data/lib/advanced_connection/railtie.rb +40 -0
  28. data/lib/advanced_connection/version.rb +29 -0
  29. data/lib/advanced_connection.rb +65 -0
  30. data/lib/generators/advanced_connection/install/USAGE +5 -0
  31. data/lib/generators/advanced_connection/install/install_generator.rb +30 -0
  32. data/lib/generators/advanced_connection/install/templates/advanced_connection.rb +142 -0
  33. data/lib/tasks/advanced_connection_tasks.rake +25 -0
  34. data/spec/config/database.yml +18 -0
  35. data/spec/config/database.yml.erb +54 -0
  36. data/spec/dummy/.gitignore +1 -0
  37. data/spec/dummy/README.rdoc +28 -0
  38. data/spec/dummy/Rakefile +6 -0
  39. data/spec/dummy/app/assets/images/.keep +0 -0
  40. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  41. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  42. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  43. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  44. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  45. data/spec/dummy/app/mailers/.keep +0 -0
  46. data/spec/dummy/app/models/.keep +0 -0
  47. data/spec/dummy/app/models/book.rb +2 -0
  48. data/spec/dummy/app/models/concerns/.keep +0 -0
  49. data/spec/dummy/app/views/layouts/application.html.erb +13 -0
  50. data/spec/dummy/bin/bundle +3 -0
  51. data/spec/dummy/bin/rails +4 -0
  52. data/spec/dummy/bin/rake +4 -0
  53. data/spec/dummy/bin/setup +29 -0
  54. data/spec/dummy/config/application.rb +32 -0
  55. data/spec/dummy/config/boot.rb +5 -0
  56. data/spec/dummy/config/database.yml +17 -0
  57. data/spec/dummy/config/environment.rb +5 -0
  58. data/spec/dummy/config/environments/development.rb +48 -0
  59. data/spec/dummy/config/environments/production.rb +79 -0
  60. data/spec/dummy/config/environments/test.rb +42 -0
  61. data/spec/dummy/config/initializers/advanced_connection.rb +142 -0
  62. data/spec/dummy/config/initializers/assets.rb +11 -0
  63. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  64. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  65. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  66. data/spec/dummy/config/initializers/inflections.rb +16 -0
  67. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  68. data/spec/dummy/config/initializers/session_store.rb +3 -0
  69. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  70. data/spec/dummy/config/locales/en.yml +23 -0
  71. data/spec/dummy/config/routes.rb +56 -0
  72. data/spec/dummy/config/secrets.yml +22 -0
  73. data/spec/dummy/config.ru +4 -0
  74. data/spec/dummy/db/migrate/20160222045238_create_books.rb +10 -0
  75. data/spec/dummy/db/schema.rb +23 -0
  76. data/spec/dummy/lib/assets/.keep +0 -0
  77. data/spec/dummy/log/.keep +0 -0
  78. data/spec/dummy/log/test.log +327 -0
  79. data/spec/dummy/public/404.html +67 -0
  80. data/spec/dummy/public/422.html +67 -0
  81. data/spec/dummy/public/500.html +66 -0
  82. data/spec/dummy/public/favicon.ico +0 -0
  83. data/spec/dummy/test/fixtures/books.yml +9 -0
  84. data/spec/dummy/test/models/book_test.rb +7 -0
  85. data/spec/idle_manager_spec.rb +16 -0
  86. data/spec/spec_helper.rb +25 -0
  87. data/spec/support/db_config.rb +61 -0
  88. metadata +399 -0
@@ -0,0 +1,27 @@
1
+ #
2
+ # Copyright (C) 2016 Finalsite, LLC
3
+ # Copyright (C) 2016 Carl P. Corliss <carl.corliss@finalsite.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+ #
22
+ module AdvancedConnection
23
+ class Error < StandardError
24
+ class ConfigError < Error; end
25
+ class UnableToReleaseConnection < Error; end
26
+ end
27
+ end
@@ -0,0 +1,40 @@
1
+ #
2
+ # Copyright (C) 2016 Finalsite, LLC
3
+ # Copyright (C) 2016 Carl P. Corliss <carl.corliss@finalsite.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+ #
22
+ module AdvancedConnection
23
+ class Railtie < Rails::Railtie
24
+ config.advanced_connection = ActiveSupport::OrderedOptions.new
25
+
26
+ ActiveSupport.on_load(:before_initialize) do
27
+ ActiveSupport.on_load(:active_record) do
28
+ # load our intitializer ASAP so we can make use of user defined configuration
29
+ load Rails.root.join('config', 'initializers', 'advanced_connection.rb')
30
+ ActiveRecord::Base.send(:include, AdvancedConnection::ActiveRecordExt)
31
+ end
32
+ end
33
+
34
+ config.after_initialize do
35
+ if AdvancedConnection.enable_idle_connection_manager && AdvancedConnection.warmup_connections
36
+ ActiveRecord::Base.connection_handler.connection_pool_list.each(&:warmup_connections)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,29 @@
1
+ #
2
+ # Copyright (C) 2016 Finalsite, LLC
3
+ # Copyright (C) 2016 Carl P. Corliss <carl.corliss@finalsite.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+ #
22
+ module AdvancedConnection
23
+ MAJOR = 0
24
+ MINOR = 5
25
+ PATCH = 1
26
+
27
+ VERSION = "%d.%d.%d" % [ MAJOR, MINOR, PATCH ]
28
+ GEM_VERSION = Gem::Version.new(VERSION)
29
+ end
@@ -0,0 +1,65 @@
1
+ #
2
+ # Copyright (C) 2016 Finalsite, LLC
3
+ # Copyright (C) 2016 Carl P. Corliss <carl.corliss@finalsite.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+ #
22
+ require 'active_record'
23
+ require 'active_support/concern'
24
+ require 'active_support/hash_with_indifferent_access'
25
+ require 'advanced_connection/version'
26
+ require 'singleton'
27
+ require 'logger'
28
+
29
+ module AdvancedConnection
30
+ extend ActiveSupport::Autoload
31
+
32
+ eager_autoload do
33
+ autoload :ActiveRecordExt
34
+ autoload :Config
35
+ autoload :Error
36
+ end
37
+
38
+ class << self
39
+ def to_h
40
+ config.to_h
41
+ end
42
+
43
+ def configure(overwrite = true)
44
+ return unless overwrite
45
+ (yield config).tap {
46
+ config.loaded!
47
+ }
48
+ end
49
+
50
+ def config
51
+ @config ||= Config.instance
52
+ end
53
+
54
+ def method_missing(method, *args, &block)
55
+ return super unless config.respond_to? method
56
+ config.public_send(method, *args, &block)
57
+ end
58
+
59
+ def respond_to_missing?(method, include_private = false)
60
+ config.respond_to?(method) || super
61
+ end
62
+ end
63
+
64
+ require 'advanced_connection/railtie' if defined?(Rails)
65
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Creates an initializer for Advanced Connection.
3
+
4
+ Example:
5
+ `rails generate advanced_connection:install`
@@ -0,0 +1,30 @@
1
+ #
2
+ # Copyright (C) 2016 Finalsite, LLC
3
+ # Copyright (C) 2016 Carl P. Corliss <carl.corliss@finalsite.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+ #
22
+ module AdvancedConnection
23
+ class InstallGenerator < Rails::Generators::Base
24
+ source_root File.expand_path('../templates', __FILE__)
25
+
26
+ def copy_files
27
+ template "advanced_connection.rb", File.join("config", "initializers", "advanced_connection.rb")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,142 @@
1
+ #
2
+ # Advanced Connection Configuration
3
+ #
4
+ AdvancedConnection.configure do |config|
5
+ #
6
+ ## Idle Manager
7
+ #
8
+ # Enabling this will enable idle connection management. This allows you to specify settings
9
+ # to enable automatic warmup of connections on rails startup, min/max idle connections and
10
+ # idle connection culling.
11
+ # config.enable_idle_connection_manager = <%= AdvancedConnection::Config::DEFAULT_CONFIG.enable_idle_connection_manager.inspect %>
12
+
13
+ # Pool queue type determines both how free connections will be checkout out
14
+ # of the pool, as well as how idle connections will be culled. The options are:
15
+ #
16
+ # :fifo - All connections will have an equal opportunity to be used and culled (default)
17
+ # :lifo/:stack - More frequently used connections will be reused, leaving less frequently used
18
+ # connections to be culled
19
+ # :prefer_older - Longer lived connections will tend to stick around longer, with younger
20
+ # connections being culled
21
+ # :prefer_younger - Younger lived connections will tend to stick around longer, with older
22
+ # connections being culled
23
+ #
24
+ # config.connection_pool_queue_type = <%= AdvancedConnection::Config::DEFAULT_CONFIG.connection_pool_queue_type.inspect %>
25
+
26
+ # How many connections to prestart on initial startup of rails. This can
27
+ # help to reduce the time it takes a restarted production node to start
28
+ # responding again.
29
+ #
30
+ # config.warmup_connections = <%= AdvancedConnection::Config::DEFAULT_CONFIG.warmup_connections.inspect %>
31
+
32
+ # Minimum number of connection to keep idle. If, during the idle check, you have fewer
33
+ # than this many connections idle, then a number of new connections will be created
34
+ # up to this this number.
35
+ #
36
+ # config.min_idle_connections = <%= AdvancedConnection::Config::DEFAULT_CONFIG.min_idle_connections.inspect %>
37
+
38
+ # Maximum number of connections that can remain idle without being culled. If you have
39
+ # more idle conections than this, only the difference between the total idle and this
40
+ # maximum will be culled.
41
+ #
42
+ # config.max_idle_connections = ::Float::INFINITY
43
+
44
+ # How long (in seconds) a connection can remain idle before being culled
45
+ #
46
+ # config.max_idle_time = 90
47
+
48
+ # How many seconds between idle checks (defaults to max_idle_time)
49
+ #
50
+ # config.idle_check_interval = 90
51
+
52
+ #
53
+ ## Without Connection
54
+ #
55
+ # Enabling this will add a new method to ActiveRecord::Base that allows you to
56
+ # mark a block of code as not requiring a connection. This can be useful in reducing
57
+ # pressure on the pool, especially when you have sections of code that make
58
+ # potentially long-lived external requests. E.g.,
59
+ #
60
+ # require 'open-uri'
61
+ # results = ActiveRecord::Base.without_connection do
62
+ # open('http://some-slow-site.com/api/foo')
63
+ # end
64
+ #
65
+ # During the call to the remote site, the db connection is checked in and subsequently
66
+ # checked back out once the block finishes.
67
+ #
68
+ # To enable this feature, uncomment the following:
69
+ #
70
+ # config.enable_without_connection = true
71
+ #
72
+ # WARNING: this feature cannot be enabled with Statement Pooling.
73
+ #
74
+ # Additionally, you can hook into the checkin / chekcout lifecycle by way of callbacks. This
75
+ # can be extremely useful when employing something like Apartment to manage switching
76
+ # between tenants.
77
+ #
78
+ # config.without_connection_callbacks = {
79
+ # # runs right before the connection is checked back into the pool
80
+ # before: ->() { },
81
+ # around: ->(&block) {
82
+ # tenant = Apartment::Tenant.current
83
+ # block.call
84
+ # Apartment::Tenant.switch(tenant)
85
+ # },
86
+ # # runs right after the connection is checked back out of the pool
87
+ # after: ->() { }
88
+ # }
89
+ #
90
+ ## Statement Pooling
91
+ #
92
+ # **** WARNING **** EXPERIMENTAL **** WARNING **** EXPERIMENTAL ****
93
+ #
94
+ # THIS FEATURE IS HIGHLY EXPERIMENTAL AND PRONE TO FAILURE. DO NOT USE UNLESS
95
+ # YOU PLAN TO AIDE IN IT'S DEVELOPMENT.
96
+ #
97
+ # When enabled, this feature causes your connections to immediately be returned to
98
+ # the pool upon completion of each query (with the exception of transactions, where
99
+ # the connection is returned after transaction commit/rollback). This can help to
100
+ # reduce pressure on the pool, as well as the number of the connections to the
101
+ # backend by making more efficient use of existing connections.
102
+ #
103
+ # WARNING: this cannot be enabled with Without Connection.
104
+ #
105
+ # To enable, simply uncomment the following:
106
+ #
107
+ # config.enable_statement_pooling = true
108
+ #
109
+ # Additionally, callbacks are provided around the connection checkin. This can
110
+ # be extremely useful when in a multi-tenant situation using something like
111
+ # Apartment, e.g.:
112
+ #
113
+ # lib/apartment/elevators/my_elevator.rb:
114
+ # module Apartment::Elevators
115
+ # class MyElevator < Generic
116
+ # def call(env)
117
+ # super
118
+ # ensure
119
+ # Thread.current[:tenant] = nil
120
+ # Apartment::Tenant.reset
121
+ # end
122
+ #
123
+ # def parse_tenant_name(request)
124
+ # request.host.split('.').first.tap do |tenant|
125
+ # Thread.current[:tenant] = tenant
126
+ # end
127
+ # end
128
+ # end
129
+ # . . .
130
+ # end
131
+ #
132
+ # and then set your statement_pooling_callbacks like so:
133
+ #
134
+ # config.statement_pooling_callbacks = {
135
+ # # switch back to the stored tenant prior to executing sql
136
+ # before: ->() {
137
+ # if Thread.current[:tenant]
138
+ # Apartment::Tenant.switch(Thread.current[:tenant])
139
+ # end
140
+ # }
141
+ # }
142
+ end
@@ -0,0 +1,25 @@
1
+ #
2
+ # Copyright (C) 2016 Finalsite, LLC
3
+ # Copyright (C) 2016 Carl P. Corliss <carl.corliss@finalsite.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+ #
22
+ # desc "Explaining what the task does"
23
+ # task :advanced_connection do
24
+ # # Task goes here
25
+ # end
@@ -0,0 +1,18 @@
1
+ default: &default
2
+ adapter: postgresql
3
+ database: advanced_connection_test
4
+ <%- if RUBY_ENGINE == 'jruby' -%>
5
+ driver: org.postgresql.Driver
6
+ url: jdbc:postgresql://localhost:5432/advanced_connection_test
7
+ <%- end -%>
8
+ pool: 50
9
+ timeout: 5000
10
+ pool_queue_type: lifo
11
+ max_idle_time: 5
12
+ max_idle_connections: 10
13
+ min_idle_connections: 5
14
+ prestart_connections: 10
15
+ dead_connection_timeout: 30
16
+
17
+ test:
18
+ <<: *default
@@ -0,0 +1,54 @@
1
+ default: &default
2
+ pool: 20
3
+ timeout: 5000
4
+ pool_queue_type: fifo
5
+ max_idle_time: 5
6
+ min_idle_connections: 5
7
+ max_idle_connections: 10
8
+ prestart_connections: 10
9
+ dead_connection_timeout: 30
10
+
11
+ default_mysql: &default_mysql
12
+ <<: *default
13
+ adapter: mysql2
14
+ database: advanced_connection_test
15
+ username: root
16
+ min_messages: WARNING
17
+
18
+ default_postgresql: &default_postgresql
19
+ <<: *default
20
+ adapter: postgresql
21
+ database: advanced_connection_test
22
+ username: postgres
23
+ min_messages: WARNING
24
+
25
+ <% if defined?(JRUBY_VERSION) %>
26
+ connections:
27
+ postgresql:
28
+ <<: *default_postgresql
29
+ driver: org.postgresql.Driver
30
+ url: jdbc:postgresql://localhost:5432/advanced_connection_test
31
+
32
+ mysql:
33
+ <<: *default_mysql
34
+ adapter: mysql
35
+ driver: com.mysql.jdbc.Driver
36
+ url: jdbc:mysql://localhost:3306/advanced_connection_test
37
+
38
+ <% else %>
39
+ connections:
40
+ postgresql:
41
+ <<: *default_postgresql
42
+ schema_search_path: public
43
+ password:
44
+
45
+ mysql:
46
+ <<: *default_mysql
47
+ adapter: mysql2
48
+ password:
49
+
50
+ sqlite:
51
+ <<: *default
52
+ adapter: sqlite3
53
+ database: <%= File.expand_path('../spec/dummy/db', __FILE__) %>/default.sqlite3
54
+ <% end %>