Class: Webhookdb::Replicator::Base::ServiceBackfiller
- Inherits:
-
Backfiller
- Object
- Backfiller
- Webhookdb::Replicator::Base::ServiceBackfiller
- Defined in:
- lib/webhookdb/replicator/base.rb
Overview
Basic backfiller that calls _fetch_backfill_page
on the given replicator. Any timeouts or 5xx errors are automatically re-enqueued for a retry. This behavior can be customized somewhat setting :backfiller_server_error_retries (default to 2) and :backfiller_server_error_backoff on the replicator (default to 63 seconds), though customization beyond that should use a custom backfiller.
Direct Known Subclasses
AtomSingleFeedV1::Backfiller, SponsyPublicationV1::Backfiller
Instance Attribute Summary collapse
-
#server_error_backoff ⇒ Object
Returns the value of attribute server_error_backoff.
-
#server_error_retries ⇒ Object
Returns the value of attribute server_error_retries.
-
#svc ⇒ Object
Returns the value of attribute svc.
Instance Method Summary collapse
- #__retryordie ⇒ Object
- #fetch_backfill_page(pagination_token, last_backfilled:) ⇒ Object
- #handle_item(item) ⇒ Object
-
#initialize(svc) ⇒ ServiceBackfiller
constructor
A new instance of ServiceBackfiller.
Methods inherited from Backfiller
#_fetch_backfill_page_with_retry, #backfill, do_retry_wait, #max_backfill_retry_attempts, #wait_for_retry_attempt
Constructor Details
#initialize(svc) ⇒ ServiceBackfiller
Returns a new instance of ServiceBackfiller.
1080 1081 1082 1083 1084 1085 1086 |
# File 'lib/webhookdb/replicator/base.rb', line 1080 def initialize(svc) @svc = svc @server_error_retries = _getifrespondto(:backfiller_server_error_retries, 2) @server_error_backoff = _getifrespondto(:backfiller_server_error_backoff, 63.seconds) raise "#{svc} must implement :_fetch_backfill_page" unless svc.respond_to?(:_fetch_backfill_page) super() end |
Instance Attribute Details
#server_error_backoff ⇒ Object
Returns the value of attribute server_error_backoff.
1078 1079 1080 |
# File 'lib/webhookdb/replicator/base.rb', line 1078 def server_error_backoff @server_error_backoff end |
#server_error_retries ⇒ Object
Returns the value of attribute server_error_retries.
1078 1079 1080 |
# File 'lib/webhookdb/replicator/base.rb', line 1078 def server_error_retries @server_error_retries end |
#svc ⇒ Object
Returns the value of attribute svc.
1076 1077 1078 |
# File 'lib/webhookdb/replicator/base.rb', line 1076 def svc @svc end |
Instance Method Details
#__retryordie ⇒ Object
1106 1107 1108 |
# File 'lib/webhookdb/replicator/base.rb', line 1106 def __retryordie raise Amigo::Retry::OrDie.new(self.server_error_retries, self.server_error_backoff) end |
#fetch_backfill_page(pagination_token, last_backfilled:) ⇒ Object
1097 1098 1099 1100 1101 1102 1103 1104 |
# File 'lib/webhookdb/replicator/base.rb', line 1097 def fetch_backfill_page(pagination_token, last_backfilled:) return @svc._fetch_backfill_page(pagination_token, last_backfilled:) rescue ::Timeout::Error, ::SocketError self.__retryordie rescue Webhookdb::Http::Error => e self.__retryordie if e.status >= 500 raise end |
#handle_item(item) ⇒ Object
1093 1094 1095 |
# File 'lib/webhookdb/replicator/base.rb', line 1093 def handle_item(item) return @svc.upsert_webhook_body(item) end |