global_uid 3.4.4 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/global_uid/base.rb +7 -28
  3. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a371e3dbfed6e0435a626259cf64906018d70e86
4
- data.tar.gz: d09a5bb556f731c8e78cef898967a9a5c3db1608
3
+ metadata.gz: a75efa773de9a27edd860de29b6c79d133b5f605
4
+ data.tar.gz: 7ddf18d558f580e5adf934a9d6b6dc2b5c49adda
5
5
  SHA512:
6
- metadata.gz: 51d65569244dfcd3b135a3e4845efc4f1325b9641dde0d437c13b54d0ce0272d15db92199047edb37806ef24019abbf9ce2a9be323e9f5350fcfc19880ebaea0
7
- data.tar.gz: 03aaad26dbef7941d438a8d0d6742fa75045e9c6e39bc367dd2b3458db3a0f0f75eec395d6f1c41840f397ba40f6b25453a24e5a635b768625681a2d16149dde
6
+ metadata.gz: 0c2752c562b662ded70c5feb9e038fcfe89ec66b30181ee1f788a66e97e47c8cc85d827819a6d70a20ad48e71a0a50aa241551d133eea2428ebc7fd1d495acd3
7
+ data.tar.gz: d7e5fb1924ab616148f33f1ac7f10f7906a6d6d8fc0b50035fe7c46dcb0b368b37adfdabf47094a7a39e2ba0d41b5d7752e2700e5a155bff8cdf5816141aab96
@@ -1,15 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  require "active_record"
3
3
  require "active_support/all"
4
-
4
+ require "mysql2"
5
5
  require "timeout"
6
6
 
7
- begin
8
- require 'mysql2'
9
- rescue LoadError
10
- end
11
-
12
-
13
7
  module GlobalUid
14
8
  class Base
15
9
  GLOBAL_UID_DEFAULTS = {
@@ -38,7 +32,6 @@ module GlobalUid
38
32
 
39
33
  engine_stmt = "ENGINE=#{global_uid_options[:storage_engine] || "MyISAM"}"
40
34
 
41
- # TODO it would be nice to be able to set the engine or something to not be MySQL specific
42
35
  with_connections do |connection|
43
36
  connection.execute("CREATE TABLE IF NOT EXISTS `#{id_table_name}` (
44
37
  `id` #{type} NOT NULL AUTO_INCREMENT,
@@ -58,17 +51,6 @@ module GlobalUid
58
51
  end
59
52
  end
60
53
 
61
- begin
62
- require 'system_timer'
63
- rescue LoadError
64
- end
65
-
66
- if const_defined?("SystemTimer")
67
- GlobalUidTimer = SystemTimer
68
- else
69
- GlobalUidTimer = Timeout
70
- end
71
-
72
54
  def self.new_connection(name, connection_timeout, offset, increment_by)
73
55
  raise "No id server '#{name}' configured in database.yml" unless ActiveRecord::Base.configurations.has_key?(name)
74
56
  config = ActiveRecord::Base.configurations[name]
@@ -76,20 +58,17 @@ module GlobalUid
76
58
 
77
59
  raise "No global_uid support for adapter #{c[:adapter]}" if c[:adapter] != 'mysql2'
78
60
 
79
- con = nil
80
61
  begin
81
- GlobalUidTimer.timeout(connection_timeout, ConnectionTimeoutException) do
82
- con = ActiveRecord::Base.send("#{c[:adapter]}_connection", config)
62
+ Timeout.timeout(connection_timeout, ConnectionTimeoutException) do
63
+ ActiveRecord::Base.mysql2_connection(config)
83
64
  end
84
65
  rescue ConnectionTimeoutException => e
85
66
  notify e, "Timed out establishing a connection to #{name}"
86
- return nil
67
+ nil
87
68
  rescue Exception => e
88
69
  notify e, "establishing a connection to #{name}: #{e.message}"
89
- return nil
70
+ nil
90
71
  end
91
-
92
- con
93
72
  end
94
73
 
95
74
  def self.init_server_info(options)
@@ -187,7 +166,7 @@ module GlobalUid
187
166
 
188
167
  def self.get_uid_for_class(klass, options = {})
189
168
  with_connections do |connection|
190
- GlobalUidTimer.timeout(self.global_uid_options[:query_timeout], TimeoutException) do
169
+ Timeout.timeout(self.global_uid_options[:query_timeout], TimeoutException) do
191
170
  id = connection.insert("REPLACE INTO #{klass.global_uid_table} (stub) VALUES ('a')")
192
171
  return id
193
172
  end
@@ -198,7 +177,7 @@ module GlobalUid
198
177
  def self.get_many_uids_for_class(klass, count, options = {})
199
178
  return [] unless count > 0
200
179
  with_connections do |connection|
201
- GlobalUidTimer.timeout(self.global_uid_options[:query_timeout], TimeoutException) do
180
+ Timeout.timeout(self.global_uid_options[:query_timeout], TimeoutException) do
202
181
  increment_by = connection.select_value("SELECT @@auto_increment_increment")
203
182
  start_id = connection.insert("REPLACE INTO #{klass.global_uid_table} (stub) VALUES " + (["('a')"] * count).join(','))
204
183
  return start_id.step(start_id + (count-1) * increment_by, increment_by).to_a
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: global_uid
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.4
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Osheroff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-08 00:00:00.000000000 Z
11
+ date: 2018-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 3.2.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.2'
22
+ version: '6.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 3.2.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.2'
32
+ version: '6.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -51,7 +51,7 @@ dependencies:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
- type: :development
54
+ type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
@@ -195,7 +195,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
195
  requirements:
196
196
  - - "~>"
197
197
  - !ruby/object:Gem::Version
198
- version: '2.0'
198
+ version: '2.3'
199
199
  required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  requirements:
201
201
  - - ">="
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  version: '0'
204
204
  requirements: []
205
205
  rubyforge_project:
206
- rubygems_version: 2.5.1
206
+ rubygems_version: 2.6.14.1
207
207
  signing_key:
208
208
  specification_version: 4
209
209
  summary: GUID