云库增加 AI识图,缓存,我的云库收藏增加安全标志
调用外部API 扣费
This commit is contained in:
1 parent
7c29e57623
commit
150e8644b7
49 files changed
+1069
-28
No files matched your search
@@ -33,6 +33,17 @@ namespace Store.Modules.CloudProduct
|
||||
new FreeSql.FreeSqlBuilder().UseConnectionString(FreeSql.DataType.MySql, connectionStringBuilder.ConnectionString)
|
||||
.UseAdoConnectionPool(true).Build());
|
||||
services.AddHostedService<CloudProductSearchStartup>();
|
||||
// 服务自行创建客户端,单例复用连接池并由容器负责释放。
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user