Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c54695c390 | |||
| c47fef80b3 | |||
| e2d2009cac | |||
| 53b422433c | |||
| 3769bb5bae | |||
| 547f8dd229 | |||
| 13be0eab87 | |||
| 5b8b1684c4 | |||
| e19f98e7ca | |||
| 8a8ed98a91 | |||
| 4b8aecc779 | |||
| f4a350b2e3 | |||
| e61f628804 | |||
| 56dbe85868 | |||
| 8fa3ac7546 | |||
| e238dcce59 | |||
| 88e70b1e81 | |||
| 36dc31e85b | |||
| 41f92d0670 |
@@ -83,6 +83,8 @@ steps:
|
||||
- mkdir -p $HOME/.kube
|
||||
- echo "$KUBE_CONFIG" > $HOME/.kube/config
|
||||
- kubectl apply -f litecharms-scheduler-uat.yml
|
||||
- sleep 10
|
||||
- kubectl rollout restart statefulset/litecharms-scheduler-uat -n litecharms-scheduler-uat
|
||||
|
||||
depends_on:
|
||||
- package
|
||||
@@ -104,6 +106,7 @@ steps:
|
||||
- mkdir -p $HOME/.kube
|
||||
- echo "$KUBE_CONFIG" > $HOME/.kube/config
|
||||
- kubectl apply -f litecharms-scheduler.yml
|
||||
- sleep 10
|
||||
- kubectl rollout restart statefulset/litecharms-scheduler -n litecharms-scheduler
|
||||
|
||||
depends_on:
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LiteCharms.Abstractions" Version="1.14.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.8" />
|
||||
<PackageReference Include="Mediator.SourceGenerator" Version="3.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
@@ -18,13 +17,12 @@
|
||||
|
||||
<!-- Lite Charms Libraries -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LiteCharms.Extensions" Version="1.14.0" />
|
||||
<PackageReference Include="LiteCharms.Features" Version="1.14.0" />
|
||||
<PackageReference Include="LiteCharms.Models" Version="1.14.0" />
|
||||
<PackageReference Include="LiteCharms.Features" Version="1.32.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Shared Global Usings -->
|
||||
<ItemGroup>
|
||||
<Using Include="Quartz" />
|
||||
<Using Include="Mediator" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,18 +1,30 @@
|
||||
using LiteCharms.Extensions;
|
||||
using LiteCharms.Features.Extensions;
|
||||
using LiteCharms.Features.Mediator;
|
||||
using LiteCharmsScheduler.Workers;
|
||||
using static LiteCharms.Abstractions.Constants;
|
||||
using static LiteCharms.Features.Email.Extensions.Constants;
|
||||
|
||||
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(LoggingPipelineBehavior<,>));
|
||||
|
||||
builder.Services.AddEmailServices(builder.Configuration);
|
||||
builder.Services.AddEmailServiceBus();
|
||||
|
||||
builder.Services.AddSalesServiceBus();
|
||||
builder.Services.AddGeneralServiceBus();
|
||||
builder.Services.AddEmailServices(builder.Configuration);
|
||||
builder.Services.AddShopDatabase(builder.Configuration);
|
||||
builder.Services.AddQuartzSchedulerClient(ShopSchedulerName, builder.Configuration);
|
||||
builder.Services.AddQuartzScheduler(ShopSchedulerName, builder.Configuration);
|
||||
|
||||
builder.Services.AddHostedService<Worker>();
|
||||
builder.Services.AddShopServices();
|
||||
builder.Services.AddShopDatabase(builder.Configuration);
|
||||
|
||||
builder.Services.AddHostedService<JobWorker>();
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using LiteCharms.Features.Quartz.Abstractions;
|
||||
using LiteCharms.Features.Shop.Notifications.Events;
|
||||
|
||||
namespace LiteCharmsScheduler.Workers
|
||||
{
|
||||
public class JobWorker(IJobOrchestrator jobOrchestrator, ILogger<JobWorker> logger, IConfiguration configuration) : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
string? emailProcessorCron = !string.IsNullOrWhiteSpace(configuration.GetSection("EmailProcessorCron").Value)
|
||||
? configuration.GetSection("EmailProcessorCron").Value
|
||||
: "0 */4 * * * ?";
|
||||
|
||||
var emailProcessorJob = ProcessEmailNotificationsEvent.Create();
|
||||
|
||||
await jobOrchestrator.ScheduleAsync(emailProcessorJob, emailProcessorCron!, stoppingToken);
|
||||
|
||||
logger.LogInformation("Startup jobs scheduled");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace LiteCharmsScheduler.Workers
|
||||
{
|
||||
public class Worker(ILogger<Worker> logger) : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
if (logger.IsEnabled(LogLevel.Information))
|
||||
{
|
||||
logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
||||
}
|
||||
await Task.Delay(1000, stoppingToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
"Host": "mail.litecharms.co.za",
|
||||
"UseSsl": true
|
||||
},
|
||||
"EmailProcessorCron": "0 */5 * * * ?",
|
||||
"Monitoring": {
|
||||
"ApiKey": "",
|
||||
"Address": "http://aspire-dashboard-service.aspire.svc.cluster.local:18889",
|
||||
@@ -15,7 +16,8 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
|
||||
@@ -17,6 +17,7 @@ data:
|
||||
Email__Host: "mail.litecharms.co.za"
|
||||
Email__Port: "465"
|
||||
Email__UseSsl: "true"
|
||||
EmailProcessorCron: "0 */5 * * * ?"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
@@ -51,7 +52,7 @@ metadata:
|
||||
namespace: litecharms-scheduler-uat
|
||||
spec:
|
||||
serviceName: "scheduler-worker-service"
|
||||
replicas: 3
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: scheduler
|
||||
@@ -74,7 +75,7 @@ spec:
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: scheduler-config
|
||||
env:
|
||||
env:
|
||||
- name: Email__Credentials__Password
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
||||
Reference in New Issue
Block a user