Class: CFTools::DEAAds

Inherits:
CF::App::Base
  • Object
show all
Defined in:
lib/tools-cf-plugin/dea-ads.rb

Instance Method Summary collapse

Instance Method Details

#dea_adsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/tools-cf-plugin/dea-ads.rb', line 18

def dea_ads
  host = input[:host]
  port = input[:port]
  user = input[:user]
  pass = input[:password]

  NATS.start(:uri => "nats://#{user}:#{pass}@#{host}:#{port}") do
    NATS.subscribe("dea.advertise") do |msg|
      payload = JSON.parse(msg)
      id = payload["id"]
      prev = advertisements[id]
      advertisements[id] = [payload, prev && prev.first]
    end

    EM.add_periodic_timer(3) do
      render_table
    end
  end
end

#preconditionObject



6
# File 'lib/tools-cf-plugin/dea-ads.rb', line 6

def precondition; end