Class ApizrRequestOptionsBuilder
- Namespace
- Apizr.Configuring.Request
- Assembly
- Apizr.dll
Builder options available at request level
public class ApizrRequestOptionsBuilder : IApizrRequestOptionsBuilder, IApizrRequestOptionsBuilder<IApizrRequestOptions, IApizrRequestOptionsBuilder>, IApizrRequestOptionsBuilderBase<IApizrRequestOptions, IApizrRequestOptionsBuilder>, IApizrGlobalSharedOptionsBuilderBase<IApizrRequestOptions, IApizrRequestOptionsBuilder>, IApizrRequestOptionsBuilderBase, IApizrGlobalSharedOptionsBuilderBase
- Inheritance
-
ApizrRequestOptionsBuilder
- Implements
- Inherited Members
- Extension Methods
Constructors
ApizrRequestOptionsBuilder(ApizrRequestOptions)
public ApizrRequestOptionsBuilder(ApizrRequestOptions options)
Parameters
optionsApizrRequestOptions
Fields
Options
protected readonly ApizrRequestOptions Options
Field Value
Methods
WithCacheClearing(bool)
Tells if you want to clear the potential cached data before requesting
public IApizrRequestOptionsBuilder WithCacheClearing(bool clearCache)
Parameters
clearCacheboolClear cache or not
Returns
WithCaching(CacheMode, TimeSpan?, bool)
Cache data.
public IApizrRequestOptionsBuilder WithCaching(CacheMode mode = CacheMode.FetchOrGet, TimeSpan? lifeSpan = null, bool shouldInvalidateOnError = false)
Parameters
modeCacheModeFetchOrGet returns fresh data when request succeed otherwise cached one, where GetOrFetch returns cached data if we get some otherwise fresh one
lifeSpanTimeSpan?This specific caching lifetime (Default: null = cache handler lifetime
shouldInvalidateOnErrorboolShould invalidate on error (Default: false)
Returns
WithCancellation(CancellationToken)
Set the cancellation token
public IApizrRequestOptionsBuilder WithCancellation(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token
Returns
WithExCatching(Action<ApizrException>, bool, ApizrDuplicateStrategy)
Catch potential exceptions
[Obsolete("Catching an exception by an Action is now replaced by a Func returning a handled boolean flag")]
public IApizrRequestOptionsBuilder WithExCatching(Action<ApizrException> onException, bool letThrowOnException = true, ApizrDuplicateStrategy strategy = ApizrDuplicateStrategy.Replace)
Parameters
onExceptionAction<ApizrException>The exception callback
letThrowOnExceptionboolLet throw potential exception (default: true)
strategyApizrDuplicateStrategyThe duplicate strategy if there's another callback already (default: Replace)
Returns
WithExCatching(Func<ApizrException, bool>, bool, ApizrDuplicateStrategy)
Catch potential exceptions
public IApizrRequestOptionsBuilder WithExCatching(Func<ApizrException, bool> onException, bool letThrowOnHandledException = true, ApizrDuplicateStrategy strategy = ApizrDuplicateStrategy.Replace)
Parameters
onExceptionFunc<ApizrException, bool>The exception callback returning handled boolean flag
letThrowOnHandledExceptionboolLet throw potential exception even if it's handled (default: true)
strategyApizrDuplicateStrategyThe duplicate strategy if there's another callback already (default: Replace)
Returns
WithExCatching(Func<ApizrException, Task<bool>>, bool, ApizrDuplicateStrategy)
Catch potential exceptions
public IApizrRequestOptionsBuilder WithExCatching(Func<ApizrException, Task<bool>> onException, bool letThrowOnHandledException = true, ApizrDuplicateStrategy strategy = ApizrDuplicateStrategy.Replace)
Parameters
onExceptionFunc<ApizrException, Task<bool>>The exception callback returning handled boolean flag Task
letThrowOnHandledExceptionboolLet throw potential exception even if it's handled (default: true)
strategyApizrDuplicateStrategyThe duplicate strategy if there's another callback already (default: Replace)
Returns
WithExCatching<TResult>(Action<ApizrException<TResult>>, bool, ApizrDuplicateStrategy)
Catch potential exceptions
[Obsolete("Catching an exception by an Action is now replaced by a Func returning a handled boolean flag")]
public IApizrRequestOptionsBuilder WithExCatching<TResult>(Action<ApizrException<TResult>> onException, bool letThrowOnException = true, ApizrDuplicateStrategy strategy = ApizrDuplicateStrategy.Replace)
Parameters
onExceptionAction<ApizrException<TResult>>The exception callback
letThrowOnExceptionboolLet throw potential exception (default: true)
strategyApizrDuplicateStrategyThe duplicate strategy if there's another callback already (default: Replace)
Returns
Type Parameters
TResult
WithExCatching<TResult>(Func<ApizrException<TResult>, bool>, bool, ApizrDuplicateStrategy)
Catch potential exceptions
public IApizrRequestOptionsBuilder WithExCatching<TResult>(Func<ApizrException<TResult>, bool> onException, bool letThrowOnHandledException = true, ApizrDuplicateStrategy strategy = ApizrDuplicateStrategy.Replace)
Parameters
onExceptionFunc<ApizrException<TResult>, bool>The exception callback returning handled boolean flag
letThrowOnHandledExceptionboolLet throw potential exception even if it's handled (default: true)
strategyApizrDuplicateStrategyThe duplicate strategy if there's another callback already (default: Replace)
Returns
Type Parameters
TResult
WithExCatching<TResult>(Func<ApizrException<TResult>, Task<bool>>, bool, ApizrDuplicateStrategy)
Catch potential exceptions
public IApizrRequestOptionsBuilder WithExCatching<TResult>(Func<ApizrException<TResult>, Task<bool>> onException, bool letThrowOnHandledException = true, ApizrDuplicateStrategy strategy = ApizrDuplicateStrategy.Replace)
Parameters
onExceptionFunc<ApizrException<TResult>, Task<bool>>The exception callback returning a handled boolean flag Task
letThrowOnHandledExceptionboolLet throw potential exception even if it's handled (default: true)
strategyApizrDuplicateStrategyThe duplicate strategy if there's another callback already (default: Replace)
Returns
Type Parameters
TResult
WithExCatching<THandler>(THandler, bool, ApizrDuplicateStrategy)
Catch potential exceptions
public IApizrRequestOptionsBuilder WithExCatching<THandler>(THandler exceptionHandler, bool letThrowOnHandledException = true, ApizrDuplicateStrategy strategy = ApizrDuplicateStrategy.Replace) where THandler : IApizrExceptionHandler
Parameters
exceptionHandlerTHandlerThe exception handler called back and returning handled boolean flag Task
letThrowOnHandledExceptionboolLet throw potential exception even if it's handled (default: true)
strategyApizrDuplicateStrategyThe duplicate strategy if there's another callback already (default: Replace)
Returns
Type Parameters
THandler
WithHandlerParameter(string, object)
Set some parameters passed through all delegating handlers
public IApizrRequestOptionsBuilder WithHandlerParameter(string key, object value)
Parameters
Returns
WithHeaders(IList<string>, ApizrDuplicateStrategy)
Add some headers to the request
public IApizrRequestOptionsBuilder WithHeaders(IList<string> headers, ApizrDuplicateStrategy strategy = ApizrDuplicateStrategy.Add)
Parameters
headersIList<string>Headers to add to the request
strategyApizrDuplicateStrategyThe duplicate strategy if there's any other already (default: Add)
Returns
WithLoggedHeadersRedactionNames(IEnumerable<string>, ApizrDuplicateStrategy)
Sets the collection of HTTP headers names for which values should be redacted before logging.
public IApizrRequestOptionsBuilder WithLoggedHeadersRedactionNames(IEnumerable<string> redactedLoggedHeaderNames, ApizrDuplicateStrategy strategy = ApizrDuplicateStrategy.Add)
Parameters
redactedLoggedHeaderNamesIEnumerable<string>The collection of HTTP headers names for which values should be redacted before logging.
strategyApizrDuplicateStrategyThe duplicate strategy if there's any other names already (default: Add)
Returns
WithLoggedHeadersRedactionRule(Func<string, bool>, ApizrDuplicateStrategy)
Sets the Func<T, TResult> which determines whether to redact the HTTP header value before logging.
public IApizrRequestOptionsBuilder WithLoggedHeadersRedactionRule(Func<string, bool> shouldRedactHeaderValue, ApizrDuplicateStrategy strategy = ApizrDuplicateStrategy.Add)
Parameters
shouldRedactHeaderValueFunc<string, bool>The Func<T, TResult> which determines whether to redact the HTTP header value before logging
strategyApizrDuplicateStrategyThe duplicate strategy if there's any other names already (default: Add)
Returns
WithLogging(HttpTracerMode, HttpMessageParts, params LogLevel[])
Define tracer mode, http traffic tracing verbosity and log levels (could be defined with LogAttribute)
public IApizrRequestOptionsBuilder WithLogging(HttpTracerMode httpTracerMode = HttpTracerMode.Everything, HttpMessageParts trafficVerbosity = HttpMessageParts.All, params LogLevel[] logLevels)
Parameters
httpTracerModeHttpTracerModetrafficVerbosityHttpMessagePartsHttp traffic tracing verbosity (default: All)
logLevelsLogLevel[]Log levels to apply while writing (default: Information)
Returns
WithOperationTimeout(TimeSpan)
Set a timeout to the operation (overall request tries)
public IApizrRequestOptionsBuilder WithOperationTimeout(TimeSpan timeout)
Parameters
timeoutTimeSpanThe operation timeout
Returns
WithRequestTimeout(TimeSpan)
Set a timeout to the request (each request try)
public IApizrRequestOptionsBuilder WithRequestTimeout(TimeSpan timeout)
Parameters
timeoutTimeSpanThe request timeout
Returns
WithResilienceContextOptions(Action<IApizrResilienceContextOptionsBuilder>)
Set some options to the resilience context
public IApizrRequestOptionsBuilder WithResilienceContextOptions(Action<IApizrResilienceContextOptionsBuilder> contextOptionsBuilder)
Parameters
contextOptionsBuilderAction<IApizrResilienceContextOptionsBuilder>The resilience context options builder
Returns
WithResiliencePipelineKeys(string[], ApizrDuplicateStrategy)
Apply some resilience strategies by getting pipelines from registry with key matching.
public IApizrRequestOptionsBuilder WithResiliencePipelineKeys(string[] resiliencePipelineKeys, ApizrDuplicateStrategy duplicateStrategy = ApizrDuplicateStrategy.Add)
Parameters
resiliencePipelineKeysstring[]Resilience pipeline keys from the registry.
duplicateStrategyApizrDuplicateStrategyThe duplicate strategy if there's any other names already (default: Add)
Returns
WithResilienceProperty<TValue>(ResiliencePropertyKey<TValue>, TValue)
Set some resilience properties to the resilience context
public IApizrRequestOptionsBuilder WithResilienceProperty<TValue>(ResiliencePropertyKey<TValue> key, TValue valueFactory)
Parameters
keyResiliencePropertyKey<TValue>The resilience property's key
valueFactoryTValue
Returns
Type Parameters
TValue