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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c6c07057db7bcc94578dac1cd86df31f4dd8668
4
- data.tar.gz: 6ec5eefd992411cd96c19ddcabe281cc6b378b2e
3
+ metadata.gz: f654aa8f8b0ea4acd474136ea1d9bf85495bd663
4
+ data.tar.gz: 320ff81e1b886b5fb1224278a16accb08436ce24
5
5
  SHA512:
6
- metadata.gz: 4fbba9347922daa7b5b9170789e5a640155e7b2fbe56ad57d9e0b1c74a1666abe9726d561495824da485992537499833725cca8f4570412c90ee0abb28a44a4c
7
- data.tar.gz: ebb94d31890dc8e10dbe62210ad2ccac24c9aa52ab269ad5d5bd8e470c7575f5b99ce0109188981982d0d98331fc8bfbbb3e5245b6e9323d67d873460b80856b
6
+ metadata.gz: 02e3b510c6f2b63c995069310113aaffb0cd765ef14e8079a3041e884c3ddd7dcc5e9af6a2d9152363a5b48f3e56650b324a9fe61f5288eb383c46441cdacb52
7
+ data.tar.gz: 30cfff827cf36b2da621d8a43a1c9f650a0292f5c73da3d8b927413b8b1713193c5478e2363920bdfbe15b78443da6a702b73252edcc60dd6dbbbcca6396e353
@@ -15,18 +15,25 @@ end
15
15
  next
16
16
  end
17
17
 
18
- PARALLEL_MAPS = (ENV['PARALLEL_MAPS'] || 4).to_i
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
- scheduler.every '5m', :first_in => '5s', :overlap => false, :timeout => '5m' do
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 (#{PARALLEL_MAPS})..."
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 thread!"
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
@@ -20,6 +20,11 @@ module Sinatra
20
20
  content_type :json
21
21
  REDIS.get "#{ENV['REDIS_KEY_PREFIX']}:orgs"
22
22
  end
23
+
24
+ app.get '/v1/last_updated' do
25
+ content_type :json
26
+ REDIS.get("#{ENV['REDIS_KEY_PREFIX']}:last_updated")
27
+ end
23
28
  end
24
29
 
25
30
  end
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.3.5
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-06 00:00:00.000000000 Z
11
+ date: 2015-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cfoundry