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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4942617dbf7d9d51672b04fdddea1ce5125ffe04
4
- data.tar.gz: 141fb1c6c2c3c8f3357164f0284c0f8d45db4ad6
3
+ metadata.gz: 875887112617bee43ab68e83eab68b49b326b6e2
4
+ data.tar.gz: 998f055c9bb7c90acd7f18710bd699a34faa5402
5
5
  SHA512:
6
- metadata.gz: ded33c645aed9b6e20336d3163f25d24c9abf8416dedc3caa075fe5c1ab8b6149d27476852ba62e1e72bcff580e550db38258bdf5f7239e00641d04a6e106435
7
- data.tar.gz: fbc54be78e690c42d328d3c347cce17fa3339667723245e77610667a30e26205d80286562be6af577921b89b4d5333cb04dfc6ba572b70c15c3505b551d539e9
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
- uid_table_name = self.global_uid_table
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
@@ -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.1
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-24 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord