Class RetryPipelineExtensions
- Namespace
- IceRpc
- Assembly
- IceRpc.Retry.dll
Provides extension methods for Pipeline to add the retry interceptor.
public static class RetryPipelineExtensions
- Inheritance
-
RetryPipelineExtensions
- Inherited Members
Methods
UseRetry(Pipeline)
Adds a RetryInterceptor that uses the default RetryOptions to the pipeline.
public static Pipeline UseRetry(this Pipeline pipeline)
Parameters
pipeline
PipelineThe pipeline being configured.
Returns
- Pipeline
The pipeline being configured.
Examples
The following code adds the retry interceptor using the default RetryOptions to the invocation pipeline.
// Create a connection cache.
await using var connectionCache = new ConnectionCache();
// Create an invocation pipeline and install the retry interceptor.
Pipeline pipeline = new Pipeline()
.UseRetry()
.Into(connectionCache);
- See Also
UseRetry(Pipeline, RetryOptions)
Adds a RetryInterceptor to the pipeline.
public static Pipeline UseRetry(this Pipeline pipeline, RetryOptions options)
Parameters
pipeline
PipelineThe pipeline being configured.
options
RetryOptionsThe options to configure the RetryInterceptor.
Returns
- Pipeline
The pipeline being configured.
Examples
The following code adds the retry interceptor using the provided RetryOptions to the invocation pipeline.
// Create a connection cache.
await using var connectionCache = new ConnectionCache();
// Create an invocation pipeline and install the retry interceptor.
Pipeline pipeline = new Pipeline()
.UseRetry(new RetryOptions
{
MaxAttempts = 5, // Make up to 5 attempts before giving up.
MaxPayloadSize = 10 * 1024, // Do not allow retries for payloads larger than 10 KB
})
.Into(connectionCache);
- See Also
UseRetry(Pipeline, RetryOptions, ILoggerFactory)
Adds a RetryInterceptor to the pipeline.
public static Pipeline UseRetry(this Pipeline pipeline, RetryOptions options, ILoggerFactory loggerFactory)
Parameters
pipeline
PipelineThe pipeline being configured.
options
RetryOptionsThe options to configure the RetryInterceptor.
loggerFactory
ILoggerFactoryThe logger factory used to create a ILogger<TCategoryName> for RetryInterceptor.
Returns
- Pipeline
The pipeline being configured.
Examples
The following code adds the retry interceptor using the provided ILoggerFactory and RetryOptions to the invocation pipeline.
// Create a connection cache.
await using var connectionCache = new ConnectionCache();
// Create a simple console logger factory and configure the log level for category IceRpc.
using ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
builder
.AddSimpleConsole()
.AddFilter("IceRpc", LogLevel.Debug));
// Create an invocation pipeline with the retry and logger interceptors.
Pipeline pipeline = new Pipeline()
.UseRetry(
// Make up to 5 attempts before giving up.
new RetryOptions { MaxAttempts = 5 },
loggerFactory)
.UseLogger(loggerFactory)
.Into(connectionCache);
- See Also