Audit.NET.Polly
27.1.0
See the version list below for details.
dotnet add package Audit.NET.Polly --version 27.1.0
NuGet\Install-Package Audit.NET.Polly -Version 27.1.0
<PackageReference Include="Audit.NET.Polly" Version="27.1.0" />
paket add Audit.NET.Polly --version 27.1.0
#r "nuget: Audit.NET.Polly, 27.1.0"
// Install Audit.NET.Polly as a Cake Addin #addin nuget:?package=Audit.NET.Polly&version=27.1.0 // Install Audit.NET.Polly as a Cake Tool #tool nuget:?package=Audit.NET.Polly&version=27.1.0
Audit.NET.Polly
Resilience wrapper Data Provider for Audit.NET library
Allows to define Polly resilience strategies to any Data Provider within Audit.NET.
Install
NuGet Package
To install the package, run the following command on the Package Manager Console:
PM> Install-Package Audit.NET.Polly
Usage
Please see the Audit.NET Readme
Configuration
To set the Polly data provider globally, call the UsePolly()
method on the fluent configuration API:
Audit.Core.Configuration.Setup()
.UsePolly(polly => polly
.DataProvider(...)
.WithResilience(r => r...)
For instance, to establish a retry policy for a RavenDB data provider, ensuring that insert/replace operations are retried no more than twice in the event of a RavenException:
var ravenDbProvider = new RavenDbDataProvider(r => r
.WithSettings(s => s
.Urls("http://127.0.0.1:8080")
.Database(_ => "Audit")));
Audit.Core.Configuration.Setup()
.UsePolly(p => p
.DataProvider(ravenDbProvider)
.WithResilience(resilience => resilience
.AddRetry(new()
{
ShouldHandle = new PredicateBuilder().Handle<RavenException>(),
Delay = TimeSpan.FromSeconds(1),
MaxRetryAttempts = 2
})));
Extension for Fallback
To facilitate the fallback to a different Data Provider you can use the FallbackToDataProvider()
extension method in the FallbackAction.
For instance, to establish a fallback policy for a RavenDB data provider, ensuring that in the event of a RavenException, the Audit Events will be written to a file using a File data provider as a fallback:
using Audit.Polly;
var ravenDbProvider = new RavenDbDataProvider(...);
var fallbakDbProvider = new FileDataProvider(...);
Audit.Core.Configuration.Setup()
.UsePolly(p => p
.DataProvider(ravenDbProvider)
.WithResilience(resilience => resilience
.AddFallback(new()
{
ShouldHandle = new PredicateBuilder().Handle<RavenException>(),
FallbackAction = args => args.FallbackToDataProvider(fallbakDbProvider)
})));
Extension for hedging
To facilitate the hedging strategy you can use the FallbackToDataProvider()
extension method in the ActionGenerator.
For instance, to establish a hedging policy for a data provider so in case of exceptions, the Audit Events will be written to a different data provider using a hedging strategy:
using Audit.Polly;
var primaryDataProvider = new SqlDataProvider(...);
var secondaryDataProvider = new FileDataProvider(...);
Audit.Core.Configuration.Setup()
.UsePolly(p => p
.DataProvider(primaryDataProvider)
.WithResilience(r => r
.AddHedging(new()
{
ShouldHandle = new PredicateBuilder().Handle<SqlException>(),
MaxHedgedAttempts = 2,
Delay = TimeSpan.Zero,
ActionGenerator = args => args.FallbackToDataProvider(secondaryDataProvider)
}));
Settings
DataProvider
: The primary data provider to use.WithResilience
: The resilience strategy to apply to the primary data provider. It can be a single policy or a collection of policies.
Resilience Strategies
The following are some of the available resilience policies to apply to the primary data provider.
AddRetry
: Adds a retry policy to the primary data provider.AddFallback
: Adds a fallback policy to the primary data provider.AddCircuitBreaker
: Adds a circuit breaker policy to the primary data provider.AddTimeout
: Adds a timeout policy to the primary data provider.AddHedging
: Adds a hedging policy to the primary data provider.
Please refer to Polly documentation for a complete list.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Audit.NET (>= 27.1.0)
- Polly.Core (>= 8.3.0)
-
.NETStandard 2.0
- Audit.NET (>= 27.1.0)
- Polly.Core (>= 8.3.0)
-
net6.0
- Audit.NET (>= 27.1.0)
- Polly.Core (>= 8.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
27.1.1 | 248 | 10/28/2024 |
27.1.0 | 320 | 10/24/2024 |
27.0.3 | 1,595 | 9/25/2024 |
27.0.2 | 321 | 9/19/2024 |
27.0.1 | 125 | 9/4/2024 |
27.0.0 | 94 | 9/3/2024 |
26.0.1 | 189 | 8/22/2024 |
26.0.0 | 2,224 | 7/19/2024 |
25.0.7 | 133 | 7/4/2024 |
25.0.6 | 128 | 6/24/2024 |
25.0.5 | 1,092 | 6/18/2024 |
25.0.4 | 1,998 | 3/24/2024 |
25.0.3 | 133 | 3/13/2024 |
25.0.2 | 214 | 3/12/2024 |
25.0.1 | 113 | 2/28/2024 |
25.0.0 | 308 | 2/16/2024 |
24.0.1 | 131 | 2/12/2024 |
24.0.0 | 114 | 2/12/2024 |