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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/barrage/generators/redis_worker_id.rb +5 -0
- data/lib/barrage/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5e6522f3f124106fc417a39339d72c0f4638c63
|
4
|
+
data.tar.gz: fca0bf19d7db713e35d6ed7f3d068176d2d48ab9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 078eeb02f1f9cefc13b4fa66f37df1363702b76b1c51896638da71a2fd7129720a6b1722837a26e28b2eaef5be03757a639b91b734acbf28f0df2614d414703c
|
7
|
+
data.tar.gz: 54e4ced79f10c2a3cba742006e055d2005caa46e6fe6b85e683e216ea6d71f436cb7424260166546fc9dbb4ed8bb00713a2fbc77a3c2abda0a1b3642a0b11968
|
data/CHANGELOG.md
CHANGED
@@ -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]
|
data/lib/barrage/version.rb
CHANGED