Sha256: bbf50869872d589726111675cc0820e6780bfa557ce20244f2c607df3b370647

Contents?: true

Size: 849 Bytes

Versions: 2

Compression:

Stored size: 849 Bytes

Contents

module DCA
  module Redis
    class Notifier
      def initialize config
        Ohm.connect :url => "redis://#{config[:host]}:#{config[:port]}"
      end

      def push(object, event, options = {})
        session = Session.find(:uid => object.session, :project => DCA.project_name, :area => object.class.queue).first
        unless session.present?
          session = Session.create :uid => object.session, :created => Time.now, :project => DCA.project_name,
                                   :area => object.class.queue
        end

        if event == :analyze
          session.inc_analyze options[:state]
        elsif event == :fetch
          session.inc_fetch options[:state], options[:result] ? :success : :failure
        elsif event == :failure
          session.add_failure options[:exception]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dca-0.1.1 lib/dca/notifier/redis/notifier.rb
dca-0.1.0 lib/dca/notifier/redis/notifier.rb