lib/rpush/daemon/delivery.rb in rpush-2.2.0-java vs lib/rpush/daemon/delivery.rb in rpush-2.3.0.rc1

- old
+ new

@@ -2,19 +2,27 @@ module Daemon class Delivery include Reflectable include Loggable - def mark_retryable(notification, deliver_after) + def mark_retryable(notification, deliver_after, error = nil) 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")}.") + @batch.mark_failed(notification, nil, "Notification failed to be delivered before #{notification.fail_after.strftime('%Y-%m-%d %H:%M:%S')}.") else + if error + log_warn("Will retry notification #{notification.id} after #{deliver_after.strftime('%Y-%m-%d %H:%M:%S')} due to error (#{error.class.name}, #{error.message})") + end @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_batch_retryable(deliver_after, error) + log_warn("Will retry #{@batch.notifications.size} notifications after #{deliver_after.strftime('%Y-%m-%d %H:%M:%S')} due to error (#{error.class.name}, #{error.message})") + @batch.mark_all_retryable(deliver_after) end def mark_delivered @batch.mark_delivered(@notification) end