Sha256: 7e4eb1f5500c9b2ea671bc7b5bbae03db9d59cd3c324dd21ded6d54b6173bcb7

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

module Rpush
  module Daemon
    class Delivery
      include Reflectable
      include Loggable

      def mark_retryable(notification, deliver_after)
        if notification.fail_after && notification.fail_after < Time.now
          @batch.mark_failed(notification, nil, "Notification failed to be delivered before #{notification.fail_after.strftime("%Y-%m-%d %H:%M:%S")}.")
        else
          @batch.mark_retryable(notification, deliver_after)
        end
      end

      def mark_retryable_exponential(notification)
        mark_retryable(notification, Time.now + 2**(notification.retries + 1))
      end

      def mark_delivered
        @batch.mark_delivered(@notification)
      end

      def mark_batch_delivered
        @batch.mark_all_delivered
      end

      def mark_failed(error)
        code = error.respond_to?(:code) ? error.code : nil
        @batch.mark_failed(@notification, code, error.to_s)
      end

      def mark_batch_failed(error)
        code = error.respond_to?(:code) ? error.code : nil
        @batch.mark_all_failed(code, error.to_s)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rpush-2.2.0-java lib/rpush/daemon/delivery.rb
rpush-2.2.0 lib/rpush/daemon/delivery.rb
rpush-2.1.0-java lib/rpush/daemon/delivery.rb
rpush-2.1.0 lib/rpush/daemon/delivery.rb
rpush-2.0.1-java lib/rpush/daemon/delivery.rb
rpush-2.0.1 lib/rpush/daemon/delivery.rb
rpush-2.0.0-java lib/rpush/daemon/delivery.rb
rpush-2.0.0 lib/rpush/daemon/delivery.rb
rpush-2.0.0.rc1-java lib/rpush/daemon/delivery.rb
rpush-2.0.0.rc1 lib/rpush/daemon/delivery.rb
rpush-2.0.0.beta2 lib/rpush/daemon/delivery.rb
rpush-2.0.0.beta1 lib/rpush/daemon/delivery.rb