Audit.NET.Polly 24.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Audit.NET.Polly --version 24.0.1                
NuGet\Install-Package Audit.NET.Polly -Version 24.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Audit.NET.Polly" Version="24.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Audit.NET.Polly --version 24.0.1                
#r "nuget: Audit.NET.Polly, 24.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Audit.NET.Polly as a Cake Addin
#addin nuget:?package=Audit.NET.Polly&version=24.0.1

// Install Audit.NET.Polly as a Cake Tool
#tool nuget:?package=Audit.NET.Polly&version=24.0.1                

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

NuGet Status NuGet Count

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 strategy 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:

var ravenDbProvider = new RavenDbDataProvider(...);

var fallbakDbProvider = new FileDataProvider(f => f.Directory(@"c:\logs"));

Audit.Core.Configuration.Setup()
    .UsePolly(p => p
        .DataProvider(ravenDbProvider)
        .WithResilience(r => r
            .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:

var primaryDataProvider = new SqlDataProvider(sqlConfig => sqlConfig...);
var secondaryDataProvider = new FileDataProvider(fileConfig => fileConfig...);

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.3.2 315 12/11/2024
27.3.1 73 12/10/2024
27.3.0 85 12/8/2024
27.2.0 141 11/23/2024
27.1.1 463 10/28/2024
27.1.0 330 10/24/2024
27.0.3 2,654 9/25/2024
27.0.2 333 9/19/2024
27.0.1 740 9/4/2024
27.0.0 106 9/3/2024
26.0.1 202 8/22/2024
26.0.0 2,286 7/19/2024
25.0.7 144 7/4/2024
25.0.6 141 6/24/2024
25.0.5 1,099 6/18/2024
25.0.4 2,012 3/24/2024
25.0.3 138 3/13/2024
25.0.2 219 3/12/2024
25.0.1 118 2/28/2024
25.0.0 313 2/16/2024
24.0.1 140 2/12/2024
24.0.0 123 2/12/2024