🐛 Fix insight

This commit is contained in:
2026-01-02 20:32:45 +08:00
parent 9c75394aa6
commit 9ecc64352c
2 changed files with 56 additions and 48 deletions

View File

@@ -1,4 +1,5 @@
using DysonNetwork.Insight; using DysonNetwork.Insight;
using DysonNetwork.Insight.Reader;
using DysonNetwork.Insight.Startup; using DysonNetwork.Insight.Startup;
using DysonNetwork.Shared.Auth; using DysonNetwork.Shared.Auth;
using DysonNetwork.Shared.Http; using DysonNetwork.Shared.Http;
@@ -11,9 +12,6 @@ builder.AddServiceDefaults();
builder.ConfigureAppKestrel(builder.Configuration); builder.ConfigureAppKestrel(builder.Configuration);
builder.Services.AddGrpc();
builder.Services.AddGrpcReflection();
builder.Services.AddControllers(); builder.Services.AddControllers();
builder.Services.AddAppServices(); builder.Services.AddAppServices();
builder.Services.AddAppAuthentication(); builder.Services.AddAppAuthentication();
@@ -41,6 +39,10 @@ using (var scope = app.Services.CreateScope())
await db.Database.MigrateAsync(); await db.Database.MigrateAsync();
} }
app.MapGrpcService<WebReaderGrpcService>();
app.MapGrpcService<WebArticleGrpcService>();
app.MapGrpcService<WebFeedGrpcService>();
app.ConfigureAppMiddleware(builder.Configuration); app.ConfigureAppMiddleware(builder.Configuration);
app.UseSwaggerManifest("DysonNetwork.Insight"); app.UseSwaggerManifest("DysonNetwork.Insight");

View File

@@ -1,5 +1,6 @@
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using DysonNetwork.Insight.Reader;
using DysonNetwork.Insight.Thought; using DysonNetwork.Insight.Thought;
using DysonNetwork.Shared.Cache; using DysonNetwork.Shared.Cache;
using DysonNetwork.Shared.Registry; using DysonNetwork.Shared.Registry;
@@ -11,60 +12,65 @@ namespace DysonNetwork.Insight.Startup;
public static class ServiceCollectionExtensions public static class ServiceCollectionExtensions
{ {
public static IServiceCollection AddAppServices(this IServiceCollection services) extension(IServiceCollection services)
{ {
services.AddDbContext<AppDatabase>(); public IServiceCollection AddAppServices()
services.AddHttpContextAccessor();
services.AddHttpClient();
// Register gRPC services
services.AddGrpc(options =>
{ {
options.EnableDetailedErrors = true; // Will be adjusted in Program.cs services.AddDbContext<AppDatabase>();
options.MaxReceiveMessageSize = 16 * 1024 * 1024; // 16MB services.AddHttpContextAccessor();
options.MaxSendMessageSize = 16 * 1024 * 1024; // 16MB
});
services.AddGrpcReflection();
// Register gRPC services services.AddHttpClient();
// Register OIDC services // Register gRPC services
services.AddControllers().AddJsonOptions(options => services.AddGrpc(options =>
{
options.EnableDetailedErrors = true; // Will be adjusted in Program.cs
options.MaxReceiveMessageSize = 16 * 1024 * 1024; // 16MB
options.MaxSendMessageSize = 16 * 1024 * 1024; // 16MB
});
services.AddGrpcReflection();
// Register gRPC services
// Register OIDC services
services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals;
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower;
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.SnakeCaseLower;
options.JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
});
return services;
}
public IServiceCollection AddAppAuthentication()
{ {
options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals; services.AddAuthorization();
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower; return services;
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.SnakeCaseLower; }
options.JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb); public IServiceCollection AddAppFlushHandlers()
}); {
services.AddSingleton<FlushBufferService>();
return services; return services;
} }
public static IServiceCollection AddAppAuthentication(this IServiceCollection services) public IServiceCollection AddAppBusinessServices()
{ {
services.AddAuthorization(); return services;
return services; }
}
public static IServiceCollection AddAppFlushHandlers(this IServiceCollection services) public IServiceCollection AddThinkingServices(IConfiguration configuration)
{ {
services.AddSingleton<FlushBufferService>(); services.AddSingleton<ThoughtProvider>();
services.AddScoped<ThoughtService>();
services.AddScoped<WebFeedService>();
services.AddScoped<WebReaderService>();
return services; return services;
} }
public static IServiceCollection AddAppBusinessServices(this IServiceCollection services)
{
return services;
}
public static IServiceCollection AddThinkingServices(this IServiceCollection services, IConfiguration configuration)
{
services.AddSingleton<ThoughtProvider>();
services.AddScoped<ThoughtService>();
return services;
} }
} }