fix(management-service): resolve ManagementService-005,008,010,011 — supervision strategy, configured command timeout, remove stale ResolveRoles path; ManagementService-012 deferred
This commit is contained in:
@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ScadaLink.Commons.Messages.Management;
|
||||
using ScadaLink.Security;
|
||||
|
||||
@@ -13,7 +14,20 @@ namespace ScadaLink.ManagementService;
|
||||
|
||||
public static class ManagementEndpoints
|
||||
{
|
||||
private static readonly TimeSpan AskTimeout = TimeSpan.FromSeconds(30);
|
||||
private static readonly TimeSpan DefaultAskTimeout = TimeSpan.FromSeconds(30);
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the ManagementActor Ask timeout from configuration
|
||||
/// (finding ManagementService-010). Falls back to <see cref="DefaultAskTimeout"/>
|
||||
/// when options are absent or the configured value is not strictly positive — a
|
||||
/// zero/negative timeout would make every management call fail immediately.
|
||||
/// </summary>
|
||||
public static TimeSpan ResolveAskTimeout(ManagementServiceOptions? options)
|
||||
{
|
||||
if (options is { CommandTimeout: { Ticks: > 0 } configured })
|
||||
return configured;
|
||||
return DefaultAskTimeout;
|
||||
}
|
||||
|
||||
public static IEndpointRouteBuilder MapManagementAPI(this IEndpointRouteBuilder endpoints)
|
||||
{
|
||||
@@ -101,10 +115,13 @@ public static class ManagementEndpoints
|
||||
var correlationId = Guid.NewGuid().ToString("N");
|
||||
var envelope = new ManagementEnvelope(authenticatedUser, command, correlationId);
|
||||
|
||||
var askTimeout = ResolveAskTimeout(
|
||||
context.RequestServices.GetService<IOptions<ManagementServiceOptions>>()?.Value);
|
||||
|
||||
object response;
|
||||
try
|
||||
{
|
||||
response = await holder.ActorRef.Ask(envelope, AskTimeout);
|
||||
response = await holder.ActorRef.Ask(envelope, askTimeout);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user