- POST /v1/in/push/send/bulk: CSV 대량 발송 (비동기) - POST /v1/in/push/job/status: Job 상태 조회 - POST /v1/in/push/job/cancel: Job 취소 - BulkJobStore: Redis Hash 기반 Job 상태 관리 - PushWorker: Job 진행률 추적 및 취소 체크 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
87 lines
3.6 KiB
C#
87 lines
3.6 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using SPMS.Application.Interfaces;
|
|
using SPMS.Application.Settings;
|
|
using SPMS.Domain.Interfaces;
|
|
using SPMS.Infrastructure.Auth;
|
|
using SPMS.Infrastructure.Caching;
|
|
using SPMS.Infrastructure.Messaging;
|
|
using SPMS.Infrastructure.Persistence;
|
|
using SPMS.Infrastructure.Push;
|
|
using SPMS.Infrastructure.Persistence.Repositories;
|
|
using SPMS.Infrastructure.Security;
|
|
using SPMS.Infrastructure.Services;
|
|
using SPMS.Infrastructure.Workers;
|
|
|
|
namespace SPMS.Infrastructure;
|
|
|
|
public static class DependencyInjection
|
|
{
|
|
public static IServiceCollection AddInfrastructure(
|
|
this IServiceCollection services,
|
|
IConfiguration configuration)
|
|
{
|
|
// DbContext
|
|
var connectionString = configuration.GetConnectionString("DefaultConnection");
|
|
services.AddDbContext<AppDbContext>(options =>
|
|
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
|
|
|
|
// UnitOfWork & Repositories
|
|
services.AddScoped<IUnitOfWork, UnitOfWork>();
|
|
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
|
services.AddScoped<IServiceRepository, ServiceRepository>();
|
|
services.AddScoped<IAdminRepository, AdminRepository>();
|
|
services.AddScoped<INoticeRepository, NoticeRepository>();
|
|
services.AddScoped<IBannerRepository, BannerRepository>();
|
|
services.AddScoped<IFaqRepository, FaqRepository>();
|
|
services.AddScoped<IAppConfigRepository, AppConfigRepository>();
|
|
services.AddScoped<IDeviceRepository, DeviceRepository>();
|
|
services.AddScoped<IFileRepository, FileRepository>();
|
|
services.AddScoped<IMessageRepository, MessageRepository>();
|
|
services.AddScoped<IPushSendLogRepository, PushSendLogRepository>();
|
|
|
|
// External Services
|
|
services.AddScoped<IJwtService, JwtService>();
|
|
services.AddSingleton<IE2EEService, E2EEService>();
|
|
services.AddSingleton<ICredentialEncryptionService, CredentialEncryptionService>();
|
|
|
|
// File Storage
|
|
services.AddSingleton<IFileStorageService, LocalFileStorageService>();
|
|
|
|
// Redis
|
|
services.Configure<RedisSettings>(configuration.GetSection(RedisSettings.SectionName));
|
|
services.AddSingleton<RedisConnection>();
|
|
services.AddSingleton<IDuplicateChecker, DuplicateChecker>();
|
|
services.AddSingleton<IScheduleCancelStore, ScheduleCancelStore>();
|
|
services.AddSingleton<IBulkJobStore, BulkJobStore>();
|
|
|
|
// RabbitMQ
|
|
services.Configure<RabbitMQSettings>(configuration.GetSection(RabbitMQSettings.SectionName));
|
|
services.AddSingleton<RabbitMQConnection>();
|
|
services.AddSingleton<RabbitMQInitializer>();
|
|
services.AddHostedService(sp => sp.GetRequiredService<RabbitMQInitializer>());
|
|
services.AddScoped<IPushQueueService, PushQueueService>();
|
|
|
|
// Push Senders
|
|
services.AddSingleton<IFcmSender, FcmSender>();
|
|
services.AddHttpClient("ApnsSender")
|
|
.ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler
|
|
{
|
|
EnableMultipleHttp2Connections = true
|
|
});
|
|
services.AddSingleton<IApnsSender, ApnsSender>();
|
|
|
|
// Workers
|
|
services.AddHostedService<PushWorker>();
|
|
services.AddHostedService<ScheduleWorker>();
|
|
|
|
// Token Store & Email Service
|
|
services.AddMemoryCache();
|
|
services.AddSingleton<ITokenStore, InMemoryTokenStore>();
|
|
services.AddSingleton<IEmailService, ConsoleEmailService>();
|
|
|
|
return services;
|
|
}
|
|
}
|