global_uid 3.0.1 → 3.1.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.
- checksums.yaml +4 -4
- data/lib/global_uid/active_record_extension.rb +6 -2
- data/lib/global_uid/base.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 875887112617bee43ab68e83eab68b49b326b6e2
|
4
|
+
data.tar.gz: 998f055c9bb7c90acd7f18710bd699a34faa5402
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7721cdf5befb1b2c26dc9d12108e1eca5b69a6073312161668024533034186957e1e939f9872db91b62adfa684c13405a87f65198ed86c49b0badec7d325e600
|
7
|
+
data.tar.gz: f893dd2fbea29c7a81e5b2d9f293b54fa517255fae1f73b72f61ba52810a2ebd350852599977018c6f24e41d99faacbba0ee64e739b3ad29f5f0dd50281777fc
|
@@ -37,11 +37,15 @@ module GlobalUid
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def generate_uid(options = {})
|
40
|
-
|
41
|
-
self.ensure_global_uid_table
|
40
|
+
ensure_global_uid_table
|
42
41
|
GlobalUid::Base.get_uid_for_class(self, options)
|
43
42
|
end
|
44
43
|
|
44
|
+
def generate_many_uids(count, options = {})
|
45
|
+
ensure_global_uid_table
|
46
|
+
GlobalUid::Base.get_many_uids_for_class(self, count, options)
|
47
|
+
end
|
48
|
+
|
45
49
|
def disable_global_uid
|
46
50
|
@global_uid_disabled = true
|
47
51
|
end
|
data/lib/global_uid/base.rb
CHANGED
@@ -195,6 +195,18 @@ module GlobalUid
|
|
195
195
|
raise NoServersAvailableException, "All global UID servers are gone!"
|
196
196
|
end
|
197
197
|
|
198
|
+
def self.get_many_uids_for_class(klass, count, options = {})
|
199
|
+
return [] unless count > 0
|
200
|
+
with_connections do |connection|
|
201
|
+
GlobalUidTimer.timeout(self.global_uid_options[:query_timeout], TimeoutException) do
|
202
|
+
increment_by = connection.select_value("SELECT @@auto_increment_increment")
|
203
|
+
start_id = connection.insert("REPLACE INTO #{klass.global_uid_table} (stub) VALUES " + (["('a')"] * count).join(','))
|
204
|
+
return start_id.step(start_id + (count-1) * increment_by, increment_by).to_a
|
205
|
+
end
|
206
|
+
end
|
207
|
+
raise NoServersAvailableException, "All global UID servers are gone!"
|
208
|
+
end
|
209
|
+
|
198
210
|
def self.global_uid_options=(options)
|
199
211
|
@global_uid_options = GLOBAL_UID_DEFAULTS.merge(options.symbolize_keys)
|
200
212
|
end
|
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.0
|
4
|
+
version: 3.1.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: 2015-02
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|