diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-04-07 21:36:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-07 21:36:58 +0200 |
commit | d4de2239b0ab04bf6a42db9f28d1fdd8e45f7d8b (patch) | |
tree | df703560743b04687d2bab7ba2ebf20de7795fca /app | |
parent | 4a9becfca2d7399acb422da646c48bdd9f39c989 (diff) |
Add a circuit breaker for ActivityPub deliveries (#7053)
Diffstat (limited to 'app')
-rw-r--r-- | app/workers/activitypub/delivery_worker.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/workers/activitypub/delivery_worker.rb b/app/workers/activitypub/delivery_worker.rb index e6cfd0d07..adffd1d3b 100644 --- a/app/workers/activitypub/delivery_worker.rb +++ b/app/workers/activitypub/delivery_worker.rb @@ -12,9 +12,7 @@ class ActivityPub::DeliveryWorker @source_account = Account.find(source_account_id) @inbox_url = inbox_url - perform_request do |response| - raise Mastodon::UnexpectedResponseError, response unless response_successful? response - end + perform_request failure_tracker.track_success! rescue => e @@ -30,8 +28,14 @@ class ActivityPub::DeliveryWorker request.add_headers(HEADERS) end - def perform_request(&block) - build_request.perform(&block) + def perform_request + light = Stoplight(@inbox_url) do + build_request.perform do |response| + raise Mastodon::UnexpectedResponseError, response unless response_successful?(response) + end + end + + light.run end def response_successful?(response) |