barrage 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: 3642f34f25aae142789e33a2cf4c1d5a01648212
4
- data.tar.gz: 3e71ac939f14b17c6c9d1d1407efda603392ea77
3
+ metadata.gz: c5e6522f3f124106fc417a39339d72c0f4638c63
4
+ data.tar.gz: fca0bf19d7db713e35d6ed7f3d068176d2d48ab9
5
5
  SHA512:
6
- metadata.gz: 6b6f8a47d16b21d6160a79b007e45622564953fc680a5f98d4acc9ca437af42fbb42d2f8c545409968c6b72b26002b9cc210646cea2068c1ff797dff3d4c1d1f
7
- data.tar.gz: 5f182c40631fe62015e9365eda727011a24943da8e1280a6bf7dc19aac1bcd959f3c5e2e79232a76d2874cd06f6714c734304abdf926ee083bcc085266f99689
6
+ metadata.gz: 078eeb02f1f9cefc13b4fa66f37df1363702b76b1c51896638da71a2fd7129720a6b1722837a26e28b2eaef5be03757a639b91b734acbf28f0df2614d414703c
7
+ data.tar.gz: 54e4ced79f10c2a3cba742006e055d2005caa46e6fe6b85e683e216ea6d71f436cb7424260166546fc9dbb4ed8bb00713a2fbc77a3c2abda0a1b3642a0b11968
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.0.4
4
+
5
+ * [redis_worker_id generator] Release current worker_id before reaching real ttl
6
+
3
7
  ## 0.0.3
4
8
 
5
9
  * Fix critical bug on redis_worker_id generator
@@ -9,6 +9,7 @@ class Barrage
9
9
  def initialize(options = {})
10
10
  @worker_id = nil
11
11
  @worker_ttl = 0
12
+ @real_ttl = 0
12
13
  super
13
14
  @data = []
14
15
  @finalizer_proc = Finalizer.new(@data)
@@ -21,6 +22,7 @@ class Barrage
21
22
  @data[1] = @worker_id = renew_worker_id
22
23
  # check redis when passed half of real ttl
23
24
  @worker_ttl = now + ttl / 2
25
+ @real_ttl = now + ttl
24
26
  end
25
27
  @worker_id
26
28
  end
@@ -54,6 +56,9 @@ class Barrage
54
56
  private
55
57
 
56
58
  def renew_worker_id
59
+ if @real_ttl - Time.now.to_i - RACE_CONDITION_TTL <= 0
60
+ @worker_id = nil
61
+ end
57
62
  new_worker_id = redis.evalsha(
58
63
  script_sha,
59
64
  argv: [2 ** length, rand(2 ** length), @worker_id, ttl, RACE_CONDITION_TTL]
@@ -1,3 +1,3 @@
1
1
  class Barrage
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barrage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - gussan