52 lines
2.8 KiB
C#
52 lines
2.8 KiB
C#
using Microsoft.Extensions.Options;
|
|
|
|
namespace MxGateway.Server.Configuration;
|
|
|
|
public sealed class GatewayConfigurationProvider(IOptions<GatewayOptions> options) : IGatewayConfigurationProvider
|
|
{
|
|
public const string RedactedValue = "[redacted]";
|
|
|
|
public EffectiveGatewayConfiguration GetEffectiveConfiguration()
|
|
{
|
|
GatewayOptions value = options.Value;
|
|
|
|
return new EffectiveGatewayConfiguration(
|
|
Authentication: new EffectiveAuthenticationConfiguration(
|
|
Mode: value.Authentication.Mode.ToString(),
|
|
SqlitePath: value.Authentication.SqlitePath,
|
|
PepperSecretName: RedactedValue,
|
|
RunMigrationsOnStartup: value.Authentication.RunMigrationsOnStartup),
|
|
Worker: new EffectiveWorkerConfiguration(
|
|
ExecutablePath: value.Worker.ExecutablePath,
|
|
WorkingDirectory: value.Worker.WorkingDirectory,
|
|
RequiredArchitecture: value.Worker.RequiredArchitecture.ToString(),
|
|
StartupTimeoutSeconds: value.Worker.StartupTimeoutSeconds,
|
|
ShutdownTimeoutSeconds: value.Worker.ShutdownTimeoutSeconds,
|
|
HeartbeatIntervalSeconds: value.Worker.HeartbeatIntervalSeconds,
|
|
HeartbeatGraceSeconds: value.Worker.HeartbeatGraceSeconds,
|
|
MaxMessageBytes: value.Worker.MaxMessageBytes),
|
|
Sessions: new EffectiveSessionConfiguration(
|
|
DefaultCommandTimeoutSeconds: value.Sessions.DefaultCommandTimeoutSeconds,
|
|
MaxSessions: value.Sessions.MaxSessions,
|
|
MaxPendingCommandsPerSession: value.Sessions.MaxPendingCommandsPerSession,
|
|
DefaultLeaseSeconds: value.Sessions.DefaultLeaseSeconds,
|
|
LeaseSweepIntervalSeconds: value.Sessions.LeaseSweepIntervalSeconds,
|
|
AllowMultipleEventSubscribers: value.Sessions.AllowMultipleEventSubscribers),
|
|
Events: new EffectiveEventConfiguration(
|
|
QueueCapacity: value.Events.QueueCapacity,
|
|
BackpressurePolicy: value.Events.BackpressurePolicy.ToString()),
|
|
Dashboard: new EffectiveDashboardConfiguration(
|
|
Enabled: value.Dashboard.Enabled,
|
|
PathBase: value.Dashboard.PathBase,
|
|
RequireAdminScope: value.Dashboard.RequireAdminScope,
|
|
AllowAnonymousLocalhost: value.Dashboard.AllowAnonymousLocalhost,
|
|
SnapshotIntervalMilliseconds: value.Dashboard.SnapshotIntervalMilliseconds,
|
|
RecentFaultLimit: value.Dashboard.RecentFaultLimit,
|
|
RecentSessionLimit: value.Dashboard.RecentSessionLimit,
|
|
ShowTagValues: value.Dashboard.ShowTagValues),
|
|
Protocol: new EffectiveProtocolConfiguration(
|
|
value.Protocol.WorkerProtocolVersion,
|
|
value.Protocol.MaxGrpcMessageBytes));
|
|
}
|
|
}
|