Sha256: bd81ce57b2121eb7562faea597d1aaa64e407feb34f201ffd5dde27335872a0d

Contents?: true

Size: 537 Bytes

Versions: 1

Compression:

Stored size: 537 Bytes

Contents

require_relative 'logger'

module Remon
  class EventProcessor

    include Logger
    attr_reader :queue

    def initialize(pr)
      @proc = pr
      @queue = Queue.new
    end

    def start
      @thread ||= Thread.new do
        logger.debug { "starting event processor" }
        loop { process_event }
      end
    end

    def process_event
      event = @queue.pop
      @proc.call event
    rescue => e
      logger.warn "warn error #{e.message}"
    end

    def stop
      Thread.kill @thread if @thread
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
remon-0.1.0 lib/remon/event_processor.rb