mysql_framework 0.1.1 → 0.1.2.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3dccb6db17fc9881471f03e6450c885a168adae746b98b913847a2499df1fc1
4
- data.tar.gz: 4fa04c68791c529d75ce4889695907c6fd5b60d06c800480550de2161608d532
3
+ metadata.gz: f327b700f17750938d41a83a10dbb3870339cc053ac9f85b8b190fcaa952ecd3
4
+ data.tar.gz: 6ee8a9ce9d1b286330cbf269bbe117c0c098690b086536e199f7da9eb93d01da
5
5
  SHA512:
6
- metadata.gz: 60be2204e33c1044793119d9e8fa6340f5960df8a0430beb47672b6687465a435f13da528e2a60d6f6667871b89f3cd25136b1f0eddc1d991131b4626c867cd9
7
- data.tar.gz: 32a4c64e9febc04f5135026e08095180acad6e9a2fd39f17d6fdca521f16978584ad3f3a3def0a0c0fc00da7a26660b6330d46350f8687f232670a13429d50b2
6
+ metadata.gz: eaf60ca0754e7df7259fa3c4ef99b75925c803a587d9ed02c628a1bbfdfb73afff9dd818223de93a0ce077bbbf20419aaaf452fd04742573af458ca8d5d30820
7
+ data.tar.gz: d30a6dfbaeb8c943339db350bfa629680974963343682b54baadc4d956bd6ab0ef16387beb5c0e257c7a6cecfd90c5849029e842f3c5cb114c9b992d612f1085
@@ -10,6 +10,8 @@ module MysqlFramework
10
10
 
11
11
  # This method is called to setup a pool of MySQL connections.
12
12
  def setup
13
+ return unless connection_pool_enabled?
14
+
13
15
  @connection_pool = ::Queue.new
14
16
 
15
17
  start_pool_size.times { @connection_pool.push(new_client) }
@@ -36,6 +38,8 @@ module MysqlFramework
36
38
 
37
39
  # This method is called to fetch a client from the connection pool.
38
40
  def check_out
41
+ return new_client unless connection_pool_enabled?
42
+
39
43
  client = @connection_pool.pop(true)
40
44
 
41
45
  client.ping if @options[:reconnect]
@@ -55,6 +59,8 @@ module MysqlFramework
55
59
 
56
60
  # This method is called to check a client back in to the connection when no longer needed.
57
61
  def check_in(client)
62
+ return client.close unless connection_pool_enabled?
63
+
58
64
  client = new_client if client.closed?
59
65
 
60
66
  @connection_pool.push(client)
@@ -128,6 +134,10 @@ module MysqlFramework
128
134
  Mysql2::Client.new(@options)
129
135
  end
130
136
 
137
+ def connection_pool_enabled?
138
+ @connection_pool_enabled ||= ENV.fetch('MYSQL_CONNECTION_POOL_ENABLED', 'true').casecmp?('true')
139
+ end
140
+
131
141
  def start_pool_size
132
142
  @start_pool_size ||= Integer(ENV.fetch('MYSQL_START_POOL_SIZE', 1))
133
143
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MysqlFramework
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2.rc1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-29 00:00:00.000000000 Z
11
+ date: 2018-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -148,9 +148,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - ">="
151
+ - - ">"
152
152
  - !ruby/object:Gem::Version
153
- version: '0'
153
+ version: 1.3.1
154
154
  requirements: []
155
155
  rubyforge_project:
156
156
  rubygems_version: 2.7.8