修复一些bug

This commit is contained in:
chfei committed 2026-11-10 09:54:12 +08:00
1 parent 9bb17a67d2
commit f4913b4fc2
7 files changed
+38 -10

No files matched your search

@@ -36,11 +36,6 @@ namespace Store.Modules.CloudProduct
// 服务自行创建客户端,单例复用连接池并由容器负责释放。
services.AddSingleton<ImageAnalysisQuotaService>();
// 图片识别沿用专用缓存库,所有请求共享并发上限。
var inspectionConnection = RequireConfiguration("ProductInspection:ConnectionString");
services.AddKeyedSingleton<IFreeSql>("ProductInspectionConnection", (_, _) =>
new FreeSql.FreeSqlBuilder().UseConnectionString(FreeSql.DataType.MySql, inspectionConnection)
.UseAdoConnectionPool(true).Build());
var maximum = Context.Configuration.GetValue<int?>("ProductInspection:MaxConcurrentAnalysis") ?? 5;
if (maximum is < 1 or > 100) throw new InvalidOperationException("识别并发数必须在 1 至 100 之间。");
services.AddKeyedSingleton<SemaphoreSlim>("ProductInspectionAnalysisGate", (_, _) => new SemaphoreSlim(maximum, maximum));