cf_light_api 1.6.4 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2b445bb4b226594c287865ab11856d26ead5ef2
4
- data.tar.gz: c35504e2c5c7650b80d8646370f199a993f9f9b8
3
+ metadata.gz: 3cff6a981946b0f933ecf05e61e1b27d710eb286
4
+ data.tar.gz: 53dec5c12b6a40f5959cb8f419a3e2877f95a137
5
5
  SHA512:
6
- metadata.gz: c5abe583323af2e9bf05da0413d48cb0fe5e637fd71194a8b860a83f643a8676aa938f4099948a61c81edcc53959203a399e95aaf9fffa1de7a694f56ca0db0d
7
- data.tar.gz: e65c0b5f048454d2551c534709c6f85be6b4dcb68534fffe1cf2c28708b894e9e54872c5447d7c8398c30cfaf83f4088497dbe213aa0a62bab0a56efa6e2ef6e
6
+ metadata.gz: 7ee0a4a4f89bef83e18792ad2ff1d9b0967599b6eea911a56a4b91dea9014c9cff9eeb5953965583b61f732fb2647a5c1d8d27e6701da654f6bc6bfaf13d9c0e
7
+ data.tar.gz: 398b8eb74e2e2888aab12197a2eb66b1dcf218de3f5053b08c79181da1cffdbd67223e8e9e103a77db30ddf2db13fdfd98b0d65fcbeb2b65954d95c82f6daf81
@@ -19,7 +19,7 @@ end
19
19
  end
20
20
 
21
21
  PARALLEL_MAPS = (ENV['PARALLEL_MAPS'] || 4 ).to_i
22
- UPDATE_INTERVAL = (ENV['UPDATE_INTERVAL'] || '5m').to_s
22
+ UPDATE_INTERVAL = (ENV['UPDATE_INTERVAL'] || '5m').to_s # If you change the default '5m' here, also remember to change the default age validity in sinatra/cf_light_api.rb:31
23
23
  UPDATE_TIMEOUT = (ENV['UPDATE_TIMEOUT'] || '5m').to_s
24
24
 
25
25
  lock_manager = Redlock::Client.new([ENV['REDIS_URI']])
@@ -58,8 +58,7 @@ scheduler.every UPDATE_INTERVAL, :first_in => '5s', :overlap => false, :timeout
58
58
  end
59
59
  end
60
60
  rescue Rufus::Scheduler::TimeoutError
61
- @logger.info 'Data update took too long and was aborted...'
62
- lock_manager.unlock(lock)
61
+ @logger.info 'Data update took too long and was aborted, waiting for the lock to expire before trying again...'
63
62
  cf_client.logout
64
63
  end
65
64
  end
@@ -23,21 +23,14 @@ module Sinatra
23
23
 
24
24
  app.get '/v1/last_updated' do
25
25
  content_type :json
26
- REDIS.get("#{ENV['REDIS_KEY_PREFIX']}:last_updated")
27
- end
26
+ updated_json = REDIS.get("#{ENV['REDIS_KEY_PREFIX']}:last_updated")
28
27
 
29
- app.get '/internal/status' do
30
- content_type :json
31
- updated = REDIS.get("#{ENV['REDIS_KEY_PREFIX']}:last_updated")
32
- last_updated = JSON.parse(updated)
33
- updated_datetime = DateTime.parse(last_updated["last_updated"])
34
- seconds_since_update = ((DateTime.now - updated_datetime) * 24 * 60 * 60).to_i
35
- if seconds_since_update >= 300
36
- status 503
37
- end
38
- "{}"
39
- end
28
+ last_updated = DateTime.parse JSON.parse(updated_json)["last_updated"]
29
+ seconds_since_update = ((DateTime.now - last_updated) * 24 * 60 * 60).to_i
40
30
 
31
+ status 503 if seconds_since_update >= (ENV['DATA_AGE_VALIDITY'] || '600'.to_i)
32
+ return updated_json
33
+ end
41
34
  end
42
35
 
43
36
  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.6.4
4
+ version: 1.6.5
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: 2016-01-05 00:00:00.000000000 Z
11
+ date: 2016-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cfoundry
@@ -116,9 +116,9 @@ executables:
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ./lib/sinatra/cf_light_api.rb
119
120
  - ./lib/cf_light_api/redis.rb
120
121
  - ./lib/cf_light_api/worker.rb
121
- - ./lib/sinatra/cf_light_api.rb
122
122
  - bin/cf_light_api
123
123
  homepage: https://github.com/springerpe/cf-light-api
124
124
  licenses:
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  requirements: []
142
142
  rubyforge_project:
143
- rubygems_version: 2.4.6
143
+ rubygems_version: 2.0.14
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: A super lightweight API for reading App and Org data from CloudFoundry, cached