Example #1
0
 private void Initialize(OrchestrationContext context)
 {
     this.Context = context;
     this.status  = new MigrateOrchestrationStatus();
     this.antaresReplatMigrationTasks = context.CreateRetryableClient <IMigrationTasks>(this.retryOptions);
     this.managementDatabaseTasks     = context.CreateRetryableClient <IManagementSqlOrchestrationTasks>(this.retryOptions);
 }
Example #2
0
            public override async Task <string> RunTask(OrchestrationContext context, bool useTypedClient)
            {
                string result;

                try
                {
                    if (useTypedClient)
                    {
                        var client = context.CreateRetryableClient <IRetryTaskClient>(this.retryPolicy);
                        result = await client.DoWork();
                    }
                    else
                    {
                        result = await context.ScheduleWithRetry <string>(DoWorkName, DoWorkVersion, this.retryPolicy);
                    }
                }
                catch (TaskFailedException ex)
                {
                    result = ex.Message;
                    if (RethrowException)
                    {
                        throw;
                    }
                }

                Result = result;
                return(result);
            }
Example #3
0
            public override async Task <string> RunTask(OrchestrationContext context, bool useTypedClient)
            {
                string result;

                try
                {
                    if (useTypedClient)
                    {
                        var client = context.CreateRetryableClient <IRetryTaskClient>(retryPolicy);
                        result = await client.DoWork();
                    }
                    else
                    {
                        result = await context.ScheduleWithRetry <string>(DO_WORK_NAME, DO_WORK_VERSION, retryPolicy);
                    }
                }
                catch (TaskFailedException e)
                {
                    result = e.Message;
                    if (rethrowException)
                    {
                        throw e;
                    }
                }

                Result = result;
                return(result);
            }
Example #4
0
            public override async Task <string> RunTask(OrchestrationContext context, string input)
            {
                string result;

                try
                {
                    var client = context.CreateRetryableClient <IRetryTaskClient>(retryPolicy);
                    result = await client.DoWork();
                }
                catch (TaskFailedException e)
                {
                    result = e.Message;
                }

                Result = result;
                return(result);
            }
        public override async Task <int> RunTask(OrchestrationContext context, int numberOfRetriesToEnforce)
        {
            var retryOptions = new RetryOptions(TimeSpan.FromSeconds(1), 5)
            {
                BackoffCoefficient = 2,
                MaxRetryInterval   = TimeSpan.FromMinutes(1),
                Handle             = RetryExceptionHandler
            };
            ITestTasks testTasks = context.CreateRetryableClient <ITestTasks>(retryOptions);
            var        result    = await testTasks.ThrowExceptionAsync(this.LatestException?.Counter - 1 ?? numberOfRetriesToEnforce);

            if (result)
            {
                return(numberOfRetriesToEnforce);
            }

            throw new Exception($"Unexpected exception thrown from {nameof(OrchestrationRunningIntoRetry)}.");
        }
Example #6
0
        public override async Task <string> RunTask(OrchestrationContext context, string input)
        {
            var instance = context.OrchestrationInstance;

            var retryOptions = new RetryOptions(TimeSpan.FromSeconds(10), 10)
            {
                BackoffCoefficient = 2,
                MaxRetryInterval   = TimeSpan.FromHours(1),

                Handle = (e) =>
                {
                    Console.WriteLine(DateTime.Now + " : " + e.Message);
                    return(true);
                }
            };

            var failedTask = context.CreateRetryableClient <IFailedTask>(retryOptions);
            await failedTask.TaskThrowEx();

            return("Succeeded");
        }
Example #7
0
            public override async Task <string> RunTask(OrchestrationContext context, GenericInterfaceOrchestrationInput input)
            {
                IGenericMethodInterface client          = context.CreateClient <IGenericMethodInterface>();
                IGenericMethodInterface retryableClient = context.CreateRetryableClient <IGenericMethodInterface>(new RetryOptions(TimeSpan.FromMilliseconds(1), 1));

                Dictionary <int, List <string> > a = await client.GetWhenTIsInput <string>(input.Property.ToString(), new[] { "test" }, new List <string>());

                Assert.IsNotNull(a);
                Assert.AreEqual(2, a[1].Count);

                GenericInterfaceOrchestrationInput[] c = await retryableClient.GetWhenMultipleGenericTypes <double, GenericInterfaceOrchestrationInput>(input.Property, input);

                Assert.IsNotNull(c);
                Assert.AreEqual(1, c.Length);

                GenericInterfaceOrchestrationInput b = await client.GetWhenNoParams <GenericInterfaceOrchestrationInput>();

                Assert.IsNull(b);

                return(string.Empty);
            }
Example #8
0
 /// <inheritdoc/>
 public override T CreateRetryableClient <T>(RetryOptions retryOptions)
 {
     PreUpdateProperties();
     return(Wrap(_innerContext.CreateRetryableClient <T>(retryOptions)));
 }