class XmlConv::Util::PollingManager

Public Class Methods

new(system) click to toggle source
# File lib/xmlconv/util/polling_manager.rb, line 173
def initialize(system)
        @system = system
end

Public Instance Methods

load_sources(&block) click to toggle source
# File lib/xmlconv/util/polling_manager.rb, line 176
def load_sources(&block)
  unless File.exist?(CONFIG.polling_file)
    SBSM.warn("Could not find #{CONFIG.polling_file}. Skip polling")
    return
  end
                          file = File.open(CONFIG.polling_file)
                          YAML.load_documents(file) { |mission|
                                  block.call(mission)
                          }
                  ensure
                          file.close if(file)
                  end
poll_sources() click to toggle source
# File lib/xmlconv/util/polling_manager.rb, line 188
                def poll_sources
@@showed_content ||= false
                        load_sources do |source|
  begin
    SBSM.info "PollingManage has source #{source.inspect}" unless @@showed_content
    source.poll { |transaction|
      @system.execute(transaction)
    }
  rescue Exception => e
    subject = 'XmlConv2 - Polling-Error'
    body = [e.class, e.message,
            defined?(source.user) ? 'user '+ source.user : nil,
            defined?(source.host) ? 'host '+ source.host : nil,
            defined?(source.port) ? 'port '+ source.port.to_s : nil
            ].compact.concat(e.backtrace).join("\n")
    Util::Mail.notify source.error_recipients, subject, body
  end
end
@@showed_content = true
                end