Skip to content
Snippets Groups Projects
Commit b4bc8e9a authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Fix: Added policy to retry Update call

parent e33cecdc
No related branches found
No related tags found
1 merge request!17BREAKING: Migrated the GraphDeployer to use the new API
......@@ -6,6 +6,7 @@ using Coscine.GraphDeployer.Utils;
using LibGit2Sharp;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Polly;
using VDS.RDF;
using static Coscine.GraphDeployer.Utils.CommandLineOptions;
using Configuration = Coscine.ApiClient.Core.Client.Configuration;
......@@ -129,11 +130,15 @@ public class Deployer(ILogger<Deployer> logger, IOptionsMonitor<GraphDeployerCon
var rdfWriter = MimeTypesHelper.GetWriter(format);
var content = VDS.RDF.Writing.StringWriter.Write(graph, rdfWriter);
if (!opts.DummyMode)
{
// Retry the operation in case of failure up to 3 times using exponential backoff (2^retryAttempt seconds as the delay between retries)
await Policy.Handle<Exception>().WaitAndRetry(3, (retryAttempt) => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))).Execute(async () =>
{
await _adminApi.UpdateMetadataGraphAsync(
graph.BaseUri.AbsoluteUri,
new MetadataUpdateAdminParameters(new RdfDefinitionForManipulationDto(content, formatEnum))
);
});
}
_logger.LogInformation("Deployed {graphName} successfully.", graphId);
......
......@@ -29,6 +29,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.4.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment