Skip to content

Commit bb9e5f7

Browse files
committed
Code improvements and regression fixes
1 parent 7a0bc56 commit bb9e5f7

5 files changed

Lines changed: 5 additions & 15 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ gem 'mysql_framework'
3434

3535
#### MySQL Connection Pooling Variables
3636

37-
* `MYSQL_CONNECTION_POOL_ENABLED` - enables/disables pooling (default: `false`)
37+
* `MYSQL_CONNECTION_POOL_ENABLED` - enables/disables pooling (default: `true`)
3838
* `MYSQL_MAX_POOL_SIZE` - how many connections should the pool be allowed to grow to (default: `5`)
3939
* `MYSQL_POOL_TIMEOUT` - how long to wait for a pooled connection before timing out (default: `5` seconds)
4040
* `MYSQL_POOL_IDLE_TIMEOUT` - how long a pooled connection can remain idle before being reaped (default: `300` seconds)

lib/mysql_framework/connector.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ def query_multiple_results(query_string, provided_client = nil)
154154
# @yield [client] block executed between BEGIN and COMMIT
155155
# @yieldparam client [Mysql2::Client]
156156
# @return [Object] block result
157-
# @raise [LocalJumpError] when no block is given
157+
# @raise [ArgumentError] when no block is given
158158
# @raise [StandardError] re-raises any exception after rollback
159159
def transaction
160-
raise LocalJumpError, 'No block was given' unless block_given?
160+
raise ArgumentError, 'No block was given' unless block_given?
161161

162162
with_client do |client|
163163
client.query('BEGIN')
@@ -198,7 +198,7 @@ def new_client
198198
def connection_pool_enabled?
199199
return @connection_pool_enabled unless @connection_pool_enabled.nil?
200200

201-
@connection_pool_enabled = ENV.fetch('MYSQL_CONNECTION_POOL_ENABLED', 'false').casecmp?('true')
201+
@connection_pool_enabled = ENV.fetch('MYSQL_CONNECTION_POOL_ENABLED', 'true').casecmp?('true')
202202
end
203203
end
204204
end

lib/mysql_framework/mysql_connection_pool.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ def start_clean_idle_connections_thread
133133
end
134134
end
135135

136-
# require 'debug'
137-
# debugger
138-
139136
@idle_connections_thread.abort_on_exception # = false
140137
@idle_connections_thread
141138
end

spec/lib/mysql_framework/connector_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
before do
3535
allow(ENV).to receive(:fetch).and_call_original
36-
allow(ENV).to receive(:fetch).with('MYSQL_CONNECTION_POOL_ENABLED', 'false')
36+
allow(ENV).to receive(:fetch).with('MYSQL_CONNECTION_POOL_ENABLED', 'true')
3737
.and_return(connection_pooling_enabled)
3838

3939
subject.setup

spec/lib/mysql_framework/mysql_connection_pool_spec.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@
7070
subject.dispose
7171
expect { subject.dispose }.not_to raise_error
7272
end
73-
74-
it 'stops the idle connection cleaner thread' do
75-
thread = subject.instance_variable_get(:@idle_connections_thread)
76-
subject.dispose
77-
sleep(6)
78-
expect(thread).not_to be_alive
79-
end
8073
end
8174

8275
describe '#pool_stats' do

0 commit comments

Comments
 (0)