private IEnumerator executeRetryOperation(RetryOperation retryOperation) { IsFetchingRegConfig = true; if (retryOperation.retryAttempt >= retryOperation.maxRetries) { IsFetchingRegConfig = false; RegConfigAttempts++; if (this.OnRegistrationConfigError != null) { this.OnRegistrationConfigError("config"); } yield break; } yield return(new WaitForSeconds(retryOperation.retryAttempt * retryOperation.retryDelay)); retryOperation.retryAttempt++; object[] args = new object[retryOperation.Args.Length + 1]; if (retryOperation.Args.Length > 0) { Array.Copy(retryOperation.Args, args, retryOperation.Args.Length); args[retryOperation.Args.Length] = retryOperation; } else { args[0] = retryOperation; } retryOperation.Method.Invoke(this, args); }
public void Fail_should_set_failed() { var summary = new RetryOperation("abc123", RetryType.FailureGroup); summary.Fail(); Assert.IsTrue(summary.Failed); }
public void Prepare_should_set_prepare_state() { var summary = new RetryOperation("abc123", RetryType.FailureGroup); summary.Prepare(1000); Assert.AreEqual(RetryState.Preparing, summary.RetryState); Assert.AreEqual(0, summary.NumberOfMessagesPrepared); Assert.AreEqual(1000, summary.TotalNumberOfMessages); }
private void getAgeBand(int age, string languageCode, RetryOperation retryOperation = null) { if (this.OnGetAgeBandStart != null) { this.OnGetAgeBandStart(); } if (retryOperation == null) { retryOperation = new RetryOperation(); retryOperation.Method = GetType().GetMethod("getAgeBand", BindingFlags.Instance | BindingFlags.NonPublic); retryOperation.Args = new object[2] { age, languageCode }; retryOperation.retryAttempt = 0; retryOperation.retryDelay = 2; retryOperation.maxRetries = 3; } RegistrationConfig.GetRegistrationAgeBand(age, languageCode, delegate(IGetAgeBandResult result) { if (this.OnGetAgeBandComplete != null) { this.OnGetAgeBandComplete(result.Success); } IsFetchingRegConfig = false; if (result.Success) { RegConfigAttempts = 0; RegistrationAgeBand = result.AgeBand; Dictionary <string, string> attributes = new Dictionary <string, string> { { "swrve.device_region", RegistrationAgeBand.CountryCode } }; Service.Get <ICPSwrveService>().UserUpdate(attributes); if (this.OnRegistrationConfigUpdated != null) { this.OnRegistrationConfigUpdated(RegistrationConfig); } } else { if (retryCoroutine != null && !retryCoroutine.Disposed) { retryCoroutine.Stop(); } retryCoroutine = CoroutineRunner.StartPersistent(executeRetryOperation(retryOperation), this, "Registration AgeBand retry"); } }); }
public void Forwarding_should_set_forwarding_state() { var summary = new RetryOperation("abc123", RetryType.FailureGroup); summary.Prepare(1000); summary.PrepareBatch(1000); summary.Forwarding(); Assert.AreEqual(RetryState.Forwarding, summary.RetryState); Assert.AreEqual(0, summary.NumberOfMessagesForwarded); Assert.AreEqual(1000, summary.TotalNumberOfMessages); }
public void Skip_should_complete_when_all_skipped() { var summary = new RetryOperation("abc123", RetryType.FailureGroup); summary.Wait(DateTime.UtcNow); summary.Prepare(1000); summary.PrepareBatch(1000); summary.Skip(1000); Assert.AreEqual(RetryState.Completed, summary.RetryState); Assert.AreEqual(1000, summary.NumberOfMessagesSkipped); }
public void Skip_should_set_update_skipped_messages() { var summary = new RetryOperation("abc123", RetryType.FailureGroup); summary.Wait(DateTime.UtcNow); summary.Prepare(2000); summary.PrepareBatch(1000); summary.Skip(1000); Assert.AreEqual(RetryState.Preparing, summary.RetryState); Assert.AreEqual(1000, summary.NumberOfMessagesSkipped); }
public void Wait_should_set_wait_state() { var summary = new RetryOperation("abc123", RetryType.FailureGroup); summary.Wait(DateTime.UtcNow, "FailureGroup1"); Assert.AreEqual(RetryState.Waiting, summary.RetryState); Assert.AreEqual(0, summary.NumberOfMessagesForwarded); Assert.AreEqual(0, summary.NumberOfMessagesPrepared); Assert.AreEqual(0, summary.NumberOfMessagesSkipped); Assert.AreEqual(0, summary.TotalNumberOfMessages); Assert.AreEqual("FailureGroup1", summary.Originator); }
public void Skip_and_forward_combination_should_complete_when_done() { var summary = new RetryOperation("abc123", RetryType.FailureGroup); summary.Wait(DateTime.UtcNow); summary.Prepare(2000); summary.PrepareBatch(1000); summary.Skip(1000); summary.Forwarding(); summary.BatchForwarded(1000); Assert.AreEqual(RetryState.Completed, summary.RetryState); Assert.AreEqual(1000, summary.NumberOfMessagesForwarded); Assert.AreEqual(1000, summary.NumberOfMessagesSkipped); }
private static RetryGroup MapOpenForForwardingOperation(string classifier, RetryBatch forwardingBatch, RetryOperation summary) { var progress = summary.GetProgress(); return(new RetryGroup { Id = forwardingBatch.RequestId, Title = forwardingBatch.Originator, Type = classifier, Count = 0, Last = summary.Last, RetryStatus = summary.RetryState.ToString(), RetryFailed = summary.Failed, RetryProgress = progress.Percentage, RetryRemainingCount = progress.MessagesRemaining, RetryCompletionTime = summary.CompletionTime, RetryStartTime = summary.Started, NeedUserAcknowledgement = false }); }
public virtual void GetRegistrationConfig(Action <IGetRegistrationConfigurationResult> callback = null, RetryOperation retryOperation = null) { if (NetworkConfigIsNotSet) { throw new NullReferenceException("NetworkServicesConfig not set"); } if (retryOperation == null) { retryOperation = new RetryOperation(); retryOperation.Method = GetType().GetMethod("GetRegistrationConfig", BindingFlags.Instance | BindingFlags.Public); retryOperation.Args = new object[1] { callback }; retryOperation.retryAttempt = 0; retryOperation.retryDelay = 2; retryOperation.maxRetries = 3; } RegistrationConfigurationGetter registrationConfigurationGetter = new RegistrationConfigurationGetter(keychainData, logger, storageDir, config.GuestControllerCDNUrl, SpoofedGeoIP, config.DisneyIdClientId, coroutineManager, config.MixAPIHostUrl, config.MixClientToken); IsFetchingRegConfig = true; if (callback == null) { if (this.OnGetRegistrationConfigStart != null) { this.OnGetRegistrationConfigStart(); } Action <IGetRegistrationConfigurationResult> callback2 = delegate(IGetRegistrationConfigurationResult result) { if (this.OnGetRegistrationConfigComplete != null) { this.OnGetRegistrationConfigComplete(result.Success); } IsFetchingRegConfig = false; if (!result.Success) { if (result is IGetRegistrationConfigurationEmbargoedCountryResult) { IsEmbargoed = true; } else { if (retryCoroutine != null && !retryCoroutine.Disposed) { retryCoroutine.Stop(); } retryCoroutine = CoroutineRunner.StartPersistent(executeRetryOperation(retryOperation), this, "Registration Config Retry"); } } else { RegistrationConfig = result.Configuration; string languageString = Service.Get <Localizer>().LanguageString; getAgeBand(1, languageString); } }; if (string.IsNullOrEmpty(OverrideCountryCode)) { registrationConfigurationGetter.Get(callback2); } else { registrationConfigurationGetter.Get(OverrideCountryCode, callback2); } } else if (string.IsNullOrEmpty(OverrideCountryCode)) { registrationConfigurationGetter.Get(callback); } else { registrationConfigurationGetter.Get(OverrideCountryCode, callback); } }
private void getUpdateAgeBand(int age, string languageCode, RetryOperation retryOperation = null) { onGetUpdateAgeBandStart(); CoroutineRunner.StartPersistent(delayGetUpdateAgeBand(), this, "delay get age band"); }
public override void GetRegistrationConfig(Action <IGetRegistrationConfigurationResult> callback = null, RetryOperation retryOperation = null) { if (NetworkConfigIsNotSet) { throw new NullReferenceException("NetworkServicesConfig not set"); } base.IsFetchingRegConfig = true; if (callback == null) { onGetRegistrationConfigStart(); CoroutineRunner.StartPersistent(registractionCallback(), this, "get registration"); } }