From 54a48f07c91e9f3b7e2b68d51b1753edf869775a Mon Sep 17 00:00:00 2001 From: g82tt Date: Tue, 19 May 2026 22:45:41 +0800 Subject: [PATCH] =?UTF-8?q?K5:=20KmsConfig+appsettings+Program.cs=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E5=B0=B1=E7=BB=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/IntegrationGateway.Host/Program.cs | 20 +++++++++++++++++++ .../IntegrationGateway.Host/appsettings.json | 10 +++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gateway/src/IntegrationGateway.Host/Program.cs b/gateway/src/IntegrationGateway.Host/Program.cs index 9764b52..12c8ce1 100644 --- a/gateway/src/IntegrationGateway.Host/Program.cs +++ b/gateway/src/IntegrationGateway.Host/Program.cs @@ -54,6 +54,17 @@ foreach (var o in owlList) registry.Register(a); } +// ── 注册 KMSAdapter(多实例遍历)── +var kmsList = app.Configuration.GetSection("KMS").Get>() ?? new(); +foreach (var k in kmsList) +{ + var code = $"KMS:{k.InstanceName ?? "default"}"; + var a = new IntegrationGateway.Adapters.Kms.KmsAdapter(code, + app.Services.GetRequiredService().CreateClient("VolPro"), + k.BaseUrl, k.ClientId, k.ClientSecret); + registry.Register(a); +} + // ── 注册 MC4Adapter(多实例遍历)── var mc4List = app.Configuration.GetSection("MC4").Get>() ?? new(); foreach (var m in mc4List) @@ -235,6 +246,15 @@ public class Mc4Config public string BaseUrl { get; set; } = ""; } +/// KMS 适配器配置项 +public class KmsConfig +{ + public string? InstanceName { get; set; } + public string BaseUrl { get; set; } = ""; + public string ClientId { get; set; } = ""; + public string ClientSecret { get; set; } = ""; +} + // ═══════════════════════════════════════════════ // B 组请求 DTO // ═══════════════════════════════════════════════ diff --git a/gateway/src/IntegrationGateway.Host/appsettings.json b/gateway/src/IntegrationGateway.Host/appsettings.json index e4d8491..a103d53 100644 --- a/gateway/src/IntegrationGateway.Host/appsettings.json +++ b/gateway/src/IntegrationGateway.Host/appsettings.json @@ -25,5 +25,13 @@ "NodeToken": "changeme", "HeartbeatIntervalSec": 15, "AdapterInitTimeoutSec": 30 - } + }, + "KMS": [ + { + "InstanceName": "main", + "BaseUrl": "http://192.168.1.50:8080", + "ClientId": "your_client_id", + "ClientSecret": "your_client_secret" + } + ] } \ No newline at end of file