magellan-gcs-proxy 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/Gemfile.lock +1 -1
- data/example/config.yml +2 -2
- data/lib/magellan/gcs/proxy/pubsub_sustainer.rb +26 -7
- data/lib/magellan/gcs/proxy/version.rb +1 -1
- 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: 50724872f81d7d6de7c7803628cd766428150f5d
|
4
|
+
data.tar.gz: bc1b1ed15f3239206268f2596b9769aa22cf683f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae86f4f6bd8b441cbc11fdd21ffa580cacbb81676d8f092b196ff961ad3924798c7d767d2c7a31e993d6b0ce67fbb6ebde99a5597bc13990c547f23158dbb40e
|
7
|
+
data.tar.gz: da279b3209b1b16931a870e260c74de94a2ecc6315ecf111b7774cdc5b3d101c73a97704e9d77a6f888bda517b591ac84050610bc87fd76f64ad64a92e315a8f
|
data/example/Gemfile.lock
CHANGED
data/example/config.yml
CHANGED
@@ -17,9 +17,9 @@ sustainer:
|
|
17
17
|
# specified by BLOCKS_BATCH_PUBSUB_SUBSCRIPTION
|
18
18
|
# You can check ACK_DEADLINE by `gcloud beta pubsub subscriptions list`
|
19
19
|
# ACK_DEADLINE is set by `--ack-deadline` option for `gcloud beta pubsub subscriptions create`.
|
20
|
-
delay: 600
|
20
|
+
delay: <%= ENV['BLOCKS_BATCH_SUSTAINER_DELAY'] || 600 %>
|
21
21
|
|
22
22
|
# interval
|
23
23
|
# The interval to send delay message. It must be lower than delay
|
24
24
|
# Default: 90% of delay
|
25
|
-
interval: 540
|
25
|
+
interval: <%= ENV['BLOCKS_BATCH_SUSTAINER_INTERVAL'] || 540 %>
|
@@ -37,28 +37,47 @@ module Magellan
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def run
|
40
|
+
reset_next_limit
|
40
41
|
loop do
|
41
42
|
debug("is sleeping #{interval} sec.")
|
42
|
-
unless wait_while_processing
|
43
|
+
unless wait_while_processing
|
43
44
|
debug('is stopping.')
|
44
45
|
break
|
45
46
|
end
|
46
|
-
|
47
|
-
|
48
|
-
debug("sent delay!(#{delay}) successfully")
|
47
|
+
send_delay
|
48
|
+
reset_next_limit
|
49
49
|
end
|
50
50
|
debug('stopped.')
|
51
51
|
rescue => e
|
52
52
|
logger.error(e)
|
53
53
|
end
|
54
54
|
|
55
|
+
attr_reader :next_limit, :next_deadline
|
56
|
+
def reset_next_limit
|
57
|
+
now = Time.now.to_f
|
58
|
+
@next_limit = now + interval
|
59
|
+
@next_deadline = now + delay
|
60
|
+
end
|
61
|
+
|
62
|
+
def send_delay
|
63
|
+
debug("is sending delay!(#{delay})")
|
64
|
+
message.delay! delay
|
65
|
+
debug("sent delay!(#{delay}) successfully")
|
66
|
+
rescue Google::Cloud::UnavailableError => e
|
67
|
+
if Time.now.to_f < next_deadline
|
68
|
+
sleep(1) # retry interval
|
69
|
+
debug("is retrying to send delay! cause of [#{e.class.name}] #{e.message}")
|
70
|
+
retry
|
71
|
+
end
|
72
|
+
raise e
|
73
|
+
end
|
74
|
+
|
55
75
|
def debug(msg)
|
56
76
|
logger.debug("#{self.class.name} #{msg}")
|
57
77
|
end
|
58
78
|
|
59
|
-
def wait_while_processing
|
60
|
-
|
61
|
-
while Time.now.to_f < limit
|
79
|
+
def wait_while_processing
|
80
|
+
while Time.now.to_f < next_limit
|
62
81
|
return false unless Thread.current[:processing_message]
|
63
82
|
sleep(0.1)
|
64
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magellan-gcs-proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akm
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|