cf_light_api 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cf_light_api/worker.rb +8 -5
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c72fd921339d1874c9b1086404e38afee9f88d5f
4
- data.tar.gz: e3f5e8773925d7515b6ecbb917054159fde095d4
3
+ metadata.gz: a80db08fc9bd5d69b56d8ae001a2cd4175e786a8
4
+ data.tar.gz: 0eadeabd636e69c5f00a2314a7ed8820133d9786
5
5
  SHA512:
6
- metadata.gz: 55bb2150f1c2d22ba2d483ddaea27b26e7649433c097531e9997478147ca06b938e0aa2fbeff2d8a45c20ef755f3e45e8cbbfd4f33e1b18623ca471c079b210b
7
- data.tar.gz: 5b30c97ec7f672fc1f50577dbdaab07cdfac22bfdbb5b8dbf2497af72803ab83df76762e2c36c31714a08a74fe05461b7d280908591e32cd0e8b361c55fbd2e5
6
+ metadata.gz: 723a44543f74b70a62073a381f3f76abe9389df01e48a284dc9c97eb09fd5c317df7f9ab09d88bb0e668343e40dce0f086d8a8ca52a48dc7566293cdb360f59a
7
+ data.tar.gz: d122b78848b14f649860f1273164c9d613e791b90a53e14bab56e56bb0d06e65a35d8770e44e0b129fdf3d2305a6f3185a7927b7c131c383e67c00762a2e3783
@@ -15,15 +15,18 @@ end
15
15
  next
16
16
  end
17
17
 
18
+ PARALLEL_MAPS = ENV['PARALLEL_MAPS'].to_i || 4
19
+
18
20
  lock_manager = Redlock::Client.new([ENV['REDIS_URI']])
19
21
  scheduler = Rufus::Scheduler.new
20
22
  scheduler.every '5m', :first_in => '5s', :overlap => false, :timeout => '5m' do
23
+ cf_client = nil
21
24
  begin
22
25
  lock_manager.lock("#{ENV['REDIS_KEY_PREFIX']}:lock", 5*60*1000) do |lock|
23
26
  if lock
24
27
  start_time = Time.now
25
28
 
26
- @logger.info "Updating data..."
29
+ @logger.info "Updating data in parallel (#{PARALLEL_MAPS})..."
27
30
 
28
31
  cf_client = get_client()
29
32
 
@@ -53,12 +56,12 @@ def get_client(cf_api=ENV['CF_API'], cf_user=ENV['CF_USER'], cf_password=ENV['CF
53
56
  end
54
57
 
55
58
  def get_app_data(cf_client)
56
- Parallel.map(cf_client.organizations, :in_processes => 4) do |org|
59
+ Parallel.map(cf_client.organizations, :in_processes => PARALLEL_MAPS) do |org|
57
60
  org_name = org.name
58
- Parallel.map(org.spaces, :in_processes => 4) do |space|
61
+ Parallel.map(org.spaces, :in_processes => PARALLEL_MAPS) do |space|
59
62
  space_name = space.name
60
63
  @logger.info "Getting app data for apps in #{org_name}:#{space_name}..."
61
- Parallel.map(space.apps, :in_processes => 4) do |app|
64
+ Parallel.map(space.apps, :in_processes => PARALLEL_MAPS) do |app|
62
65
  begin
63
66
  # It's possible for an app to have been terminated before this stage is reached.
64
67
  format_app_data(app, org_name, space_name)
@@ -71,7 +74,7 @@ def get_app_data(cf_client)
71
74
  end
72
75
 
73
76
  def get_org_data(cf_client)
74
- Parallel.map( cf_client.organizations, :in_processes => 4) do |org|
77
+ Parallel.map( cf_client.organizations, :in_processes => PARALLEL_MAPS) do |org|
75
78
  org_name = org.name
76
79
  @logger.info "Getting org data for #{org_name}..."
77
80
  # The CFoundry client returns memory_limit in MB, so we need to normalise to Bytes to match the Apps.
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.2
4
+ version: 1.3.3
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-05-27 00:00:00.000000000 Z
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cfoundry
@@ -102,9 +102,9 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
+ - ./lib/sinatra/cf_light_api.rb
105
106
  - ./lib/cf_light_api/redis.rb
106
107
  - ./lib/cf_light_api/worker.rb
107
- - ./lib/sinatra/cf_light_api.rb
108
108
  - bin/cf_light_api
109
109
  homepage: https://github.com/springerpe/cf-light-api
110
110
  licenses:
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 2.4.6
129
+ rubygems_version: 2.0.14
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: A super lightweight API for reading App and Org data from CloudFoundry, cached