Class: Postman::Runner
- Inherits:
-
Object
- Object
- Postman::Runner
- Defined in:
- lib/postman/runner.rb
Instance Method Summary collapse
-
#initialize(config_file) ⇒ Runner
constructor
A new instance of Runner.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(config_file) ⇒ Runner
Returns a new instance of Runner.
4 5 6 7 8 |
# File 'lib/postman/runner.rb', line 4 def initialize(config_file) @config = YAML.load_file(config_file) @logger = Logger.new(@config['log']) @running = true end |
Instance Method Details
#start ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/postman/runner.rb', line 14 def start ft = Thread.new do fetcher = Postman::Fetcher.new(@config) while @running @logger.info "Fetcher: downloaded #{fetcher.fetch} emails | inbox: #{fetcher.inbox_size} | total processed: #{fetcher.process_count}" sleep 30 end @logger.info('Fetcher finished') end pt = Thread.new do processor = Postman::Processor.new(@config) while @running @logger.info "Processor: processing..." processor.process sleep 30 end @logger.info('Processor finished') end ft.join pt.join end |
#stop ⇒ Object
10 11 12 |
# File 'lib/postman/runner.rb', line 10 def stop @running = false end |