https://github.com/futurum-dev/dotnet.futurum.core.polly
Small dotnet library, allowing you to use Polly with Futurum.Core, based on the concepts behind 'Railway Oriented Programming'.
https://github.com/futurum-dev/dotnet.futurum.core.polly
csharp dotnet functional-programming polly polly-resilience railway-oriented-programming result-type
Last synced: 2 months ago
JSON representation
Small dotnet library, allowing you to use Polly with Futurum.Core, based on the concepts behind 'Railway Oriented Programming'.
- Host: GitHub
- URL: https://github.com/futurum-dev/dotnet.futurum.core.polly
- Owner: futurum-dev
- License: mit
- Created: 2022-02-02T20:00:00.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-04-07T12:19:45.000Z (almost 3 years ago)
- Last Synced: 2025-08-01T01:41:44.367Z (8 months ago)
- Topics: csharp, dotnet, functional-programming, polly, polly-resilience, railway-oriented-programming, result-type
- Language: C#
- Homepage: https://docs.futurum.dev/
- Size: 63.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Futurum.Core.Polly


[](https://coveralls.io/github/futurum-dev/dotnet.futurum.core.polly?branch=main)
[](https://www.nuget.org/packages/futurum.core.polly)
Small dotnet library, allowing you to use [Polly](https://github.com/App-vNext/Polly) with Futurum.Core, based on the concepts behind 'Railway Oriented Programming'.
### Try
Try to run func, using the Polly policy. If the policy fails, the failing result will be returned as a failure.
```csharp
var result = await ResultPolly.TryAsync(func, () => ERROR_MESSAGE, pollyPolicy);
```
### ThenTry
Combines Result.Then with ResultPolly.Try
```csharp
var outputResult = await inputResult.ThenTryAsync(func, () => ERROR_MESSAGE, pollyPolicy);
```
### HandleResult
Create a policy to handle Result
```csharp
Policy.Handle()
.HandleResult()
```
### HandleResult<T>
Create a policy to handle Result<T>
```csharp
Policy.Handle()
.HandleResult()
```
### DelegateResult extensions
#### GetErrorMessage
Get the error message either from the Exception or the Result / Result<T>
```csharp
var errorMessage = delegateResult.GetErrorMessage()
```
```csharp
_pollyPolicy = Policy.Handle()
.HandleResult()
.WaitAndRetryAsync(new []{TimeSpan.FromSeconds(5), },
(delegateResult, timeSpan, retryCount, context) =>
{
var error = delegateResult.GetErrorMessage();
_logger.LogWarning("Retry - retryCount: '{RetryCount}'. Error : '{Error}'", retryCount, error);
});
```
#### DelegateResult GetErrorMessageSafe
Get the safe error message either from the Exception or the Result / Result<T>
```csharp
var errorMessage = delegateResult.GetErrorMessageSafe()
```
```csharp
_pollyPolicy = Policy.Handle()
.HandleResult()
.WaitAndRetryAsync(new []{TimeSpan.FromSeconds(5), },
(delegateResult, timeSpan, retryCount, context) =>
{
var error = delegateResult.GetErrorMessageSafe();
_logger.LogWarning("Retry - retryCount: '{RetryCount}'. Error : '{Error}'", retryCount, error);
});
```