ColinChang.Hystrix
1.0.4
Install-Package ColinChang.Hystrix -Version 1.0.4
dotnet add package ColinChang.Hystrix --version 1.0.4
<PackageReference Include="ColinChang.Hystrix" Version="1.0.4" />
paket add ColinChang.Hystrix --version 1.0.4
#r "nuget: ColinChang.Hystrix, 1.0.4"
// Install ColinChang.Hystrix as a Cake Addin
#addin nuget:?package=ColinChang.Hystrix&version=1.0.4
// Install ColinChang.Hystrix as a Cake Tool
#tool nuget:?package=ColinChang.Hystrix&version=1.0.4
Hystrix
This is a light AOP framework that allows you to use Polly
to handle exceptions with some policies like circuit break or fallback and so on of your .net core application.It's like Hystrix from Java Platform.
- Based on
Polly
andAspectCore.Core
. - Used as Attribute conveniently.
- Class must be
public
and method must bevirtual
.
Sample:
[Hystrix(nameof(RetryTestFallBackAsync), MaxRetryTimes = 3, EnableCircuitBreaker = true)]
public virtual async Task<string> RetryTestAsync(string str)//It must be virtual method
{
Console.WriteLine(nameof(RetryTestAsync));
str.ToString();
return await Task.FromResult("ok" + str);
}
public async Task<string> RetryTestFallBackAsync(string name)
{
Console.WriteLine(nameof(RetryTestFallBackAsync));
return "RetryTestFallBackAsync";
}
We provide 2 samples to show how to use this in Console and Asp.Net Core.
Advanced
The link below explain its theory and how it works.
https://colin-chang.site/netcore/pages/microservice-polly.html
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows |
.NET Core | netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard2.0 netstandard2.1 |
.NET Framework | net461 net462 net463 net47 net471 net472 net48 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.NETStandard 2.0
- AspectCore.Core (>= 1.2.0)
- Microsoft.Extensions.Caching.Memory (>= 2.2.0)
- Microsoft.Extensions.Logging.Abstractions (>= 2.2.0)
- Polly (>= 7.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
change the return value of "RegisterAssemblyTypes“ for a fluent style programming