Add delivery failure handling to FASP jobs (#35723)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
# capabilities :jsonb not null
|
||||
# confirmed :boolean default(FALSE), not null
|
||||
# contact_email :string
|
||||
# delivery_last_failed_at :datetime
|
||||
# fediverse_account :string
|
||||
# name :string not null
|
||||
# privacy_policy :jsonb
|
||||
@@ -22,6 +23,8 @@
|
||||
class Fasp::Provider < ApplicationRecord
|
||||
include DebugConcern
|
||||
|
||||
RETRY_INTERVAL = 1.hour
|
||||
|
||||
has_many :fasp_backfill_requests, inverse_of: :fasp_provider, class_name: 'Fasp::BackfillRequest', dependent: :delete_all
|
||||
has_many :fasp_debug_callbacks, inverse_of: :fasp_provider, class_name: 'Fasp::DebugCallback', dependent: :delete_all
|
||||
has_many :fasp_subscriptions, inverse_of: :fasp_provider, class_name: 'Fasp::Subscription', dependent: :delete_all
|
||||
@@ -122,6 +125,16 @@ class Fasp::Provider < ApplicationRecord
|
||||
@delivery_failure_tracker ||= DeliveryFailureTracker.new(base_url, resolution: :minutes)
|
||||
end
|
||||
|
||||
def available?
|
||||
delivery_failure_tracker.available? || retry_worthwile?
|
||||
end
|
||||
|
||||
def update_availability!
|
||||
self.delivery_last_failed_at = (Time.current unless delivery_failure_tracker.available?)
|
||||
|
||||
save!
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_keypair
|
||||
@@ -148,4 +161,8 @@ class Fasp::Provider < ApplicationRecord
|
||||
Fasp::Request.new(self).delete(path)
|
||||
end
|
||||
end
|
||||
|
||||
def retry_worthwile?
|
||||
delivery_last_failed_at && delivery_last_failed_at < RETRY_INTERVAL.ago
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user