Sha256: 23b358c11c6ed7b419ee6d6d0f26a8226eeca6b8abf9f13125008e8bf3eec4a4

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

# This worker handles Envelopes dispatch
class MailCannon::Barrel
  include Sidekiq::Worker
  
  def perform(envelope_id)
    envelope_id = envelope_id['$oid'] if envelope_id['$oid']
    shoot!(envelope_id)
  end

  private
  def shoot!(envelope_id)
    logger.info "sending MailCannon::Envelope.find('#{envelope_id}')"
    begin
      envelope = MailCannon::Envelope.find(envelope_id.to_s)
      if envelope.valid?
        response = envelope.send!
        unless response==true
          raise response
        end
      end
    rescue Mongoid::Errors::DocumentNotFound
      logger.error "unable to find the document MailCannon::Envelope.find('#{envelope_id}')"
    rescue Exception => e
      logger.error "unable to send MailCannon::Envelope.find('#{envelope_id}') #{e.backtrace}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mailcannon-0.1.0.pre.1 lib/mailcannon/workers/barrel.rb
mailcannon-0.0.8.pre.1 lib/mailcannon/workers/barrel.rb