mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-06-05 17:14:23 -04:00
Use Failsafe
This commit is contained in:
parent
659c499bd0
commit
65c5df89f4
3 changed files with 10 additions and 9 deletions
|
@ -21,9 +21,9 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Failsafe" Version="1.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||
<PackageReference Include="Onova" Version="2.2.0" />
|
||||
<PackageReference Include="Polly" Version="6.1.2" />
|
||||
<PackageReference Include="Scriban" Version="1.2.9" />
|
||||
<PackageReference Include="Tyrrrz.Extensions" Version="1.5.1" />
|
||||
<PackageReference Include="Tyrrrz.Settings" Version="1.3.3" />
|
||||
|
|
|
@ -8,7 +8,7 @@ using DiscordChatExporter.Core.Exceptions;
|
|||
using DiscordChatExporter.Core.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using DiscordChatExporter.Core.Internal;
|
||||
using Polly;
|
||||
using Failsafe;
|
||||
using Tyrrrz.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Services
|
||||
|
@ -20,13 +20,14 @@ namespace DiscordChatExporter.Core.Services
|
|||
private async Task<JToken> GetApiResponseAsync(AuthToken token, string resource, string endpoint,
|
||||
params string[] parameters)
|
||||
{
|
||||
// Create request policy
|
||||
var policy = Policy
|
||||
.Handle<HttpErrorStatusCodeException>(e => (int) e.StatusCode == 429)
|
||||
.WaitAndRetryAsync(10, i => TimeSpan.FromSeconds(0.4));
|
||||
// Create retry policy
|
||||
var retry = Retry.Create()
|
||||
.Catch<HttpErrorStatusCodeException>(false, e => (int) e.StatusCode == 429)
|
||||
.WithMaxTryCount(10)
|
||||
.WithDelay(TimeSpan.FromSeconds(0.4));
|
||||
|
||||
// Send request
|
||||
return await policy.ExecuteAsync(async () =>
|
||||
return await retry.ExecuteAsync(async () =>
|
||||
{
|
||||
// Create request
|
||||
const string apiRoot = "https://discordapp.com/api/v6";
|
||||
|
|
|
@ -32,8 +32,8 @@ DiscordChatExporter can be used to export message history from a [Discord](https
|
|||
- [MaterialDesignInXamlToolkit](https://github.com/ButchersBoy/MaterialDesignInXamlToolkit)
|
||||
- [Newtonsoft.Json](http://www.newtonsoft.com/json)
|
||||
- [Scriban](https://github.com/lunet-io/scriban)
|
||||
- [Polly](https://github.com/App-vNext/Polly)
|
||||
- [Onova](https://github.com/Tyrrrz/Onova)
|
||||
- [CommandLineParser](https://github.com/commandlineparser/commandline)
|
||||
- [Failsafe](https://github.com/Tyrrrz/Failsafe)
|
||||
- [Onova](https://github.com/Tyrrrz/Onova)
|
||||
- [Tyrrrz.Extensions](https://github.com/Tyrrrz/Extensions)
|
||||
- [Tyrrrz.Settings](https://github.com/Tyrrrz/Settings)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue