Example #1
0
        private async Task <SyncResult> AttempSegmentSync(string name, long targetChangeNumber, FetchOptions fetchOptions, int maxRetries, int?retryDelayMs, bool withBackoff)
        {
            try
            {
                var remainingAttempts = maxRetries;

                if (withBackoff)
                {
                    _backOffSplits.Reset();
                }

                while (true)
                {
                    remainingAttempts--;
                    await _segmentFetcher.Fetch(name, fetchOptions);

                    if (targetChangeNumber <= _segmentCache.GetChangeNumber(name))
                    {
                        return(new SyncResult(true, remainingAttempts));
                    }
                    else if (remainingAttempts <= 0)
                    {
                        return(new SyncResult(false, remainingAttempts));
                    }

                    var delay = withBackoff ? _backOffSplits.GetInterval(inMiliseconds: true) : retryDelayMs.Value;
                    _wrapperAdapter.TaskDelay((int)delay).Wait();
                }
            }
            catch (Exception ex)
            {
                _log.Debug("Exception while AttempSplitsSync.", ex);
            }

            return(new SyncResult(false, 0));
        }
Example #2
0
        public async Task SynchronizeSegment(string segmentName)
        {
            await _segmentFetcher.Fetch(segmentName);

            _log.Debug($"Segment fetched: {segmentName}...");
        }