K5: KmsConfig+appsettings+Program.cs注册就绪

This commit is contained in:
2026-05-19 22:45:41 +08:00
parent 641125b993
commit 54a48f07c9
2 changed files with 29 additions and 1 deletions

View File

@@ -54,6 +54,17 @@ foreach (var o in owlList)
registry.Register(a); registry.Register(a);
} }
// ── 注册 KMSAdapter多实例遍历──
var kmsList = app.Configuration.GetSection("KMS").Get<List<KmsConfig>>() ?? new();
foreach (var k in kmsList)
{
var code = $"KMS:{k.InstanceName ?? "default"}";
var a = new IntegrationGateway.Adapters.Kms.KmsAdapter(code,
app.Services.GetRequiredService<IHttpClientFactory>().CreateClient("VolPro"),
k.BaseUrl, k.ClientId, k.ClientSecret);
registry.Register(a);
}
// ── 注册 MC4Adapter多实例遍历── // ── 注册 MC4Adapter多实例遍历──
var mc4List = app.Configuration.GetSection("MC4").Get<List<Mc4Config>>() ?? new(); var mc4List = app.Configuration.GetSection("MC4").Get<List<Mc4Config>>() ?? new();
foreach (var m in mc4List) foreach (var m in mc4List)
@@ -235,6 +246,15 @@ public class Mc4Config
public string BaseUrl { get; set; } = ""; public string BaseUrl { get; set; } = "";
} }
/// <summary>KMS 适配器配置项</summary>
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 // B 组请求 DTO
// ═══════════════════════════════════════════════ // ═══════════════════════════════════════════════

View File

@@ -25,5 +25,13 @@
"NodeToken": "changeme", "NodeToken": "changeme",
"HeartbeatIntervalSec": 15, "HeartbeatIntervalSec": 15,
"AdapterInitTimeoutSec": 30 "AdapterInitTimeoutSec": 30
} },
"KMS": [
{
"InstanceName": "main",
"BaseUrl": "http://192.168.1.50:8080",
"ClientId": "your_client_id",
"ClientSecret": "your_client_secret"
}
]
} }