Class: Rse::Subscriber

Inherits:
SPSSub
  • Object
show all
Defined in:
lib/rse.rb

Instance Method Summary collapse

Constructor Details

#initialize(host: 'rse.home', spshost: 'sps.home') ⇒ Subscriber

Returns a new instance of Subscriber.



56
57
58
59
60
61
# File 'lib/rse.rb', line 56

def initialize(host: 'rse.home', spshost: 'sps.home')

  @rsc = RSC.new(host)
  super(host: spshost)

end

Instance Method Details

#subscribe(topic: 'rse/#') ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rse.rb', line 63

def subscribe(topic: 'rse/#')

  super(topic: topic) do |msg, topic|

    a = topic.split('/')[1..-1]

    if a.length < 2 then

      begin
        r = @rsc.run_job(a.first, msg)
      rescue
        self.notice 'rse_result: no job ' + a.first
      end

      self.notice 'rse_result: ' + r.inspect

    else

      package, job = a

      begin
        r = @rsc.run_job(package, job, {}, msg)
      rescue
        self.notice 'rse_result: no job ' + a.first
      end

      self.notice "rse_result/%s/%s: %s" % [package, job, r.inspect ]
    end

  end
end