cf_light_api 1.3.5 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cf_light_api/worker.rb +13 -5
- data/lib/sinatra/cf_light_api.rb +5 -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: f654aa8f8b0ea4acd474136ea1d9bf85495bd663
|
4
|
+
data.tar.gz: 320ff81e1b886b5fb1224278a16accb08436ce24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02e3b510c6f2b63c995069310113aaffb0cd765ef14e8079a3041e884c3ddd7dcc5e9af6a2d9152363a5b48f3e56650b324a9fe61f5288eb383c46441cdacb52
|
7
|
+
data.tar.gz: 30cfff827cf36b2da621d8a43a1c9f650a0292f5c73da3d8b927413b8b1713193c5478e2363920bdfbe15b78443da6a702b73252edcc60dd6dbbbcca6396e353
|
data/lib/cf_light_api/worker.rb
CHANGED
@@ -15,18 +15,25 @@ end
|
|
15
15
|
next
|
16
16
|
end
|
17
17
|
|
18
|
-
PARALLEL_MAPS
|
18
|
+
PARALLEL_MAPS = (ENV['PARALLEL_MAPS'] || 4 ).to_i
|
19
|
+
UPDATE_INTERVAL = (ENV['UPDATE_INTERVAL'] || '5m').to_s
|
20
|
+
UPDATE_TIMEOUT = (ENV['UPDATE_TIMEOUT'] || '5m').to_s
|
19
21
|
|
20
22
|
lock_manager = Redlock::Client.new([ENV['REDIS_URI']])
|
21
23
|
scheduler = Rufus::Scheduler.new
|
22
|
-
|
24
|
+
|
25
|
+
@logger.info "Parallel maps: '#{PARALLEL_MAPS}'"
|
26
|
+
@logger.info "Update interval: '#{UPDATE_INTERVAL}'"
|
27
|
+
@logger.info "Update timeout: '#{UPDATE_TIMEOUT}'"
|
28
|
+
|
29
|
+
scheduler.every UPDATE_INTERVAL, :first_in => '5s', :overlap => false, :timeout => UPDATE_TIMEOUT do
|
23
30
|
cf_client = nil
|
24
31
|
begin
|
25
32
|
lock_manager.lock("#{ENV['REDIS_KEY_PREFIX']}:lock", 5*60*1000) do |lock|
|
26
33
|
if lock
|
27
34
|
start_time = Time.now
|
28
35
|
|
29
|
-
@logger.info "Updating data in parallel
|
36
|
+
@logger.info "Updating data in parallel..."
|
30
37
|
|
31
38
|
cf_client = get_client()
|
32
39
|
|
@@ -35,17 +42,18 @@ scheduler.every '5m', :first_in => '5s', :overlap => false, :timeout => '5m' do
|
|
35
42
|
|
36
43
|
put_in_redis "#{ENV['REDIS_KEY_PREFIX']}:orgs", org_data
|
37
44
|
put_in_redis "#{ENV['REDIS_KEY_PREFIX']}:apps", app_data
|
38
|
-
put_in_redis "#{ENV['REDIS_KEY_PREFIX']}:last_updated", Time.now
|
45
|
+
put_in_redis "#{ENV['REDIS_KEY_PREFIX']}:last_updated", {:last_updated => Time.now}
|
39
46
|
|
40
47
|
@logger.info "Update completed in #{format_duration(Time.now.to_f - start_time.to_f)}..."
|
41
48
|
lock_manager.unlock(lock)
|
42
49
|
cf_client.logout
|
43
50
|
else
|
44
|
-
@logger.info "Update already running in another
|
51
|
+
@logger.info "Update already running in another instance!"
|
45
52
|
end
|
46
53
|
end
|
47
54
|
rescue Rufus::Scheduler::TimeoutError
|
48
55
|
@logger.info 'Data update took too long and was aborted...'
|
56
|
+
lock_manager.unlock(lock)
|
49
57
|
cf_client.logout
|
50
58
|
end
|
51
59
|
end
|
data/lib/sinatra/cf_light_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cf_light_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Springer Platform Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cfoundry
|