Ejemplo n.º 1
0
            static async Task ExecuteWithRetries(Func <Task> task, IClientConnectionRetryFilter retryFilter, CancellationToken cancellationToken)
            {
                do
                {
                    try
                    {
                        await task();

                        return;
                    }
                    catch (Exception exception) when(retryFilter is not null && !cancellationToken.IsCancellationRequested)
                    {
                        var shouldRetry = await retryFilter.ShouldRetryConnectionAttempt(exception, cancellationToken);

                        if (cancellationToken.IsCancellationRequested || !shouldRetry)
                        {
                            throw;
                        }
                    }
                }while (!cancellationToken.IsCancellationRequested);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Configures the provided delegate as a connection retry filter, used to determine whether initial connection to the Orleans cluster should be retried after a failure.
 /// </summary>
 /// <param name="builder">The host builder.</param>
 /// <param name="connectionRetryFilter">The connection retry filter.</param>
 /// <returns>The same instance of the <see cref="IClientBuilder"/> for chaining.</returns>
 public static IClientBuilder UseConnectionRetryFilter(this IClientBuilder builder, IClientConnectionRetryFilter connectionRetryFilter)
 {
     return(builder.ConfigureServices(collection => collection.AddSingleton <IClientConnectionRetryFilter>(connectionRetryFilter)));
 }