Fixed email sending logic
continuous-integration/drone/pr Build is passing

This commit is contained in:
Khwezi Mngoma
2026-05-16 00:32:22 +02:00
parent 547f8dd229
commit 53b422433c
5 changed files with 16 additions and 7 deletions
@@ -17,11 +17,12 @@
<!-- Lite Charms Libraries --> <!-- Lite Charms Libraries -->
<ItemGroup> <ItemGroup>
<PackageReference Include="LiteCharms.Features" Version="1.27.0" /> <PackageReference Include="LiteCharms.Features" Version="1.32.0" />
</ItemGroup> </ItemGroup>
<!-- Shared Global Usings --> <!-- Shared Global Usings -->
<ItemGroup> <ItemGroup>
<Using Include="Quartz" /> <Using Include="Quartz" />
<Using Include="Mediator" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+6 -3
View File
@@ -1,12 +1,15 @@
using LiteCharms.Features.Extensions; using LiteCharms.Features.Extensions;
using LiteCharms.Features.Mediator; using LiteCharms.Features.Mediator;
using LiteCharmsScheduler.Workers; using LiteCharmsScheduler.Workers;
using Mediator;
using static LiteCharms.Features.Email.Extensions.Constants; using static LiteCharms.Features.Email.Extensions.Constants;
var builder = Host.CreateApplicationBuilder(args); var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddMediator(); builder.Services.AddMediator(options => options.Assemblies = new List<AssemblyReference>
{
typeof(Program).Assembly,
typeof(LiteCharms.Features.Shop.Notifications.Events.ProcessEmailNotificationsEvent).Assembly
}.AsReadOnly());
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(TelemetryPipelineBehavior<,>)); builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(TelemetryPipelineBehavior<,>));
builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineBehavior<,>)); builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineBehavior<,>));
@@ -16,7 +19,7 @@ builder.Services.AddEmailServiceBus();
builder.Services.AddSalesServiceBus(); builder.Services.AddSalesServiceBus();
builder.Services.AddGeneralServiceBus(); builder.Services.AddGeneralServiceBus();
builder.Services.AddQuartzSchedulerClient(ShopSchedulerName, builder.Configuration); builder.Services.AddQuartzScheduler(ShopSchedulerName, builder.Configuration);
builder.Services.AddShopServices(); builder.Services.AddShopServices();
builder.Services.AddShopDatabase(builder.Configuration); builder.Services.AddShopDatabase(builder.Configuration);
+5 -1
View File
@@ -5,9 +5,13 @@ namespace LiteCharmsScheduler.Workers
{ {
public class JobWorker(IJobOrchestrator jobOrchestrator, ILogger<JobWorker> logger) : BackgroundService public class JobWorker(IJobOrchestrator jobOrchestrator, ILogger<JobWorker> logger) : BackgroundService
{ {
private const string emailProcessorCron = "0 */5 * * * ?";
protected override async Task ExecuteAsync(CancellationToken stoppingToken) protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{ {
await jobOrchestrator.ScheduleAsync(ProcessEmailNotificationsEvent.Create(), "0 */5 * * * ?", stoppingToken); var emailProcessorJob = ProcessEmailNotificationsEvent.Create();
await jobOrchestrator.ScheduleAsync(emailProcessorJob, emailProcessorCron, stoppingToken);
logger.LogInformation("Startup jobs scheduled"); logger.LogInformation("Startup jobs scheduled");
} }
+2 -1
View File
@@ -15,7 +15,8 @@
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning",
"Microsoft.EntityFrameworkCore": "Warning"
} }
}, },
"AllowedHosts": "*" "AllowedHosts": "*"
+1 -1
View File
@@ -51,7 +51,7 @@ metadata:
namespace: litecharms-scheduler-uat namespace: litecharms-scheduler-uat
spec: spec:
serviceName: "scheduler-worker-service" serviceName: "scheduler-worker-service"
replicas: 3 replicas: 1
selector: selector:
matchLabels: matchLabels:
app: scheduler app: scheduler