Class: CFTools::DEAApps
- Inherits:
-
CF::App::Base
- Object
- CF::App::Base
- CFTools::DEAApps
- Defined in:
- lib/tools-cf-plugin/dea-apps.rb
Instance Method Summary collapse
Instance Method Details
#dea_apps ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tools-cf-plugin/dea-apps.rb', line 18 def dea_apps @seen_apps = {} host = input[:host] port = input[:port] user = input[:user] pass = input[:password] render_apps("nats://#{user}:#{pass}@#{host}:#{port}") end |
#precondition ⇒ Object
6 |
# File 'lib/tools-cf-plugin/dea-apps.rb', line 6 def precondition; end |
#render_apps(uri) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tools-cf-plugin/dea-apps.rb', line 29 def render_apps(uri) NATS.start(:uri => uri) do NATS.subscribe("dea.advertise") do |msg| payload = JSON.parse(msg) dea_id = payload["id"] advertisements[dea_id] = payload["app_id_to_count"] end EM.add_periodic_timer(3) do render_table end end rescue NATS::ServerError => e if e.to_s =~ /slow consumer/i line c("dropped by server; reconnecting...", :error) retry end end |