mirror of
https://github.com/postalserver/postal.git
synced 2026-10-19 10:46:32 +00:00
Change retry and batching timing calculations (#2371)
This patch changes the requeue behaviour to requeue messages that are 30 seconds past their retry time. Batching now includes messages that are any amount past their retry time. This change avoids batching messages before theur graylisting time, but maintains efficient batching.
This commit is contained in:
@@ -36,10 +36,11 @@ class QueuedMessage < ApplicationRecord
|
|||||||
after_commit :queue, on: :create
|
after_commit :queue, on: :create
|
||||||
|
|
||||||
scope :unlocked, -> { where(locked_at: nil) }
|
scope :unlocked, -> { where(locked_at: nil) }
|
||||||
scope :retriable, -> { where("retry_after IS NULL OR retry_after <= ?", 30.seconds.from_now) }
|
scope :retriable, -> { where("retry_after IS NULL OR retry_after < ?", Time.now) }
|
||||||
|
scope :requeueable, -> { where("retry_after IS NULL OR retry_after < ?", 30.seconds.ago) }
|
||||||
|
|
||||||
def retriable?
|
def retriable?
|
||||||
retry_after.nil? || retry_after <= 30.seconds.from_now
|
retry_after.nil? || retry_after < Time.now
|
||||||
end
|
end
|
||||||
|
|
||||||
def queue
|
def queue
|
||||||
@@ -117,7 +118,7 @@ class QueuedMessage < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.requeue_all
|
def self.requeue_all
|
||||||
unlocked.retriable.each(&:queue)
|
unlocked.requeueable.each(&:queue)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user