@@ -6,8 +6,6 @@ class Synchronizer
66 include SplitIoClient ::Cache ::Fetchers
77 include SplitIoClient ::Cache ::Senders
88
9- ON_DEMAND_FETCH_BACKOFF_BASE_SECONDS = 10
10- ON_DEMAND_FETCH_BACKOFF_MAX_WAIT_SECONDS = 60
119 ON_DEMAND_FETCH_BACKOFF_MAX_RETRIES = 10
1210
1311 def initialize (
@@ -27,6 +25,9 @@ def initialize(
2725 @telemetry_synchronizer = params [ :telemetry_synchronizer ]
2826 @impressions_sender_adapter = params [ :impressions_sender_adapter ]
2927 @unique_keys_tracker = params [ :unique_keys_tracker ]
28+
29+ @splits_sync_backoff = Engine ::BackOff . new ( 10 , 0 , 60 )
30+ @segments_sync_backoff = Engine ::BackOff . new ( 10 , 0 , 60 )
3031 end
3132
3233 def sync_all ( asynchronous = true )
@@ -140,7 +141,7 @@ def fetch_segment(name, target_change_number)
140141
141142 def attempt_segment_sync ( name , target_cn , fetch_options , max_retries , retry_delay_seconds , with_backoff )
142143 remaining_attempts = max_retries
143- backoff = Engine :: BackOff . new ( ON_DEMAND_FETCH_BACKOFF_BASE_SECONDS , 0 , ON_DEMAND_FETCH_BACKOFF_MAX_WAIT_SECONDS ) if with_backoff
144+ @segments_sync_backoff . reset
144145
145146 loop do
146147 remaining_attempts -= 1
@@ -150,14 +151,14 @@ def attempt_segment_sync(name, target_cn, fetch_options, max_retries, retry_dela
150151 return sync_result ( true , remaining_attempts ) if target_cn <= @segments_repository . get_change_number ( name ) . to_i
151152 return sync_result ( false , remaining_attempts ) if remaining_attempts <= 0
152153
153- delay = with_backoff ? backoff . interval : retry_delay_seconds
154+ delay = with_backoff ? @segments_sync_backoff . interval : retry_delay_seconds
154155 sleep ( delay )
155156 end
156157 end
157158
158159 def attempt_splits_sync ( target_cn , fetch_options , max_retries , retry_delay_seconds , with_backoff )
159160 remaining_attempts = max_retries
160- backoff = Engine :: BackOff . new ( ON_DEMAND_FETCH_BACKOFF_BASE_SECONDS , 0 , ON_DEMAND_FETCH_BACKOFF_MAX_WAIT_SECONDS ) if with_backoff
161+ @splits_sync_backoff . reset
161162
162163 loop do
163164 remaining_attempts -= 1
@@ -167,7 +168,7 @@ def attempt_splits_sync(target_cn, fetch_options, max_retries, retry_delay_secon
167168 return sync_result ( true , remaining_attempts , result [ :segment_names ] ) if target_cn <= @splits_repository . get_change_number
168169 return sync_result ( false , remaining_attempts , result [ :segment_names ] ) if remaining_attempts <= 0
169170
170- delay = with_backoff ? backoff . interval : retry_delay_seconds
171+ delay = with_backoff ? @splits_sync_backoff . interval : retry_delay_seconds
171172 sleep ( delay )
172173 end
173174 end
0 commit comments