diff --git a/LiteCharmsScheduler/LiteCharmsScheduler.csproj b/LiteCharmsScheduler/LiteCharmsScheduler.csproj index d48bd4e..7698d64 100644 --- a/LiteCharmsScheduler/LiteCharmsScheduler.csproj +++ b/LiteCharmsScheduler/LiteCharmsScheduler.csproj @@ -8,6 +8,7 @@ + all @@ -17,7 +18,7 @@ - + diff --git a/LiteCharmsScheduler/Program.cs b/LiteCharmsScheduler/Program.cs index 509358b..eb35640 100644 --- a/LiteCharmsScheduler/Program.cs +++ b/LiteCharmsScheduler/Program.cs @@ -1,15 +1,12 @@ using LiteCharms.Features.Extensions; using LiteCharms.Features.Mediator; +using LiteCharms.Features.MidrandBooks.Extensions; using LiteCharmsScheduler.Workers; -using static LiteCharms.Features.Email.Extensions.Constants; +using static LiteCharms.Features.Extensions.Quartz; var builder = Host.CreateApplicationBuilder(args); -builder.Services.AddMediator(options => options.Assemblies = new List - { - typeof(Program).Assembly, - typeof(LiteCharms.Features.Shop.Notifications.Events.ProcessEmailNotificationsEvent).Assembly - }.AsReadOnly()); +builder.Services.AddMediator(); builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(TelemetryPipelineBehavior<,>)); builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineBehavior<,>)); @@ -17,19 +14,18 @@ builder.Services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingPipelineB builder.Services.AddEmailServices(builder.Configuration); builder.Services.AddEmailServiceBus(); -builder.Services.AddSalesServiceBus(); -builder.Services.AddGeneralServiceBus(); -builder.Services.AddQuartzScheduler(ShopSchedulerName, builder.Configuration); - builder.Services.AddShopServices(); -builder.Services.AddShopDatabase(builder.Configuration); +builder.Services.AddHashServices(builder.Configuration); +builder.Services.AddMidrandShopDatabase(builder.Configuration); + +builder.Services.AddQuartzScheduler(MidrandShopSchedulerName, builder.Configuration); builder.Services.AddHostedService(); var host = builder.Build(); var schedulerFactory = host.Services.GetRequiredService(); -var scheduler = await schedulerFactory.GetScheduler(ShopSchedulerName); +var scheduler = await schedulerFactory.GetScheduler(MidrandShopSchedulerName); if (!scheduler!.IsStarted) await scheduler.Start(); diff --git a/LiteCharmsScheduler/Workers/JobWorker.cs b/LiteCharmsScheduler/Workers/JobWorker.cs index 3b7532a..57b0661 100644 --- a/LiteCharmsScheduler/Workers/JobWorker.cs +++ b/LiteCharmsScheduler/Workers/JobWorker.cs @@ -1,21 +1,10 @@ using LiteCharms.Features.Quartz.Abstractions; -using LiteCharms.Features.Shop.Notifications.Events; namespace LiteCharmsScheduler.Workers { public class JobWorker(IJobOrchestrator jobOrchestrator, ILogger 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"); - } + protected override async Task ExecuteAsync(CancellationToken stoppingToken) => + logger.LogInformation("Midrand Books jobs initialized"); } } diff --git a/LiteCharmsScheduler/appsettings.json b/LiteCharmsScheduler/appsettings.json index ffa88a2..c32928d 100644 --- a/LiteCharmsScheduler/appsettings.json +++ b/LiteCharmsScheduler/appsettings.json @@ -1,18 +1,19 @@ { - "Email": { - "Credentials": { - "Username": "shop@litecharms.co.za" - }, - "Port": 465, - "Host": "mail.litecharms.co.za", - "UseSsl": true + "HasherSettings": { + "MinHashLength": 11 + }, + "BookshopS3Settings": { + "ServiceUrl": "http://192.168.1.177:30900", + "Region": "garage", + "BucketName": "bookshop", + "CdnBaseUrl": "https://bookshop.cdn.khongisa.co.za" }, - "EmailProcessorCron": "0 */5 * * * ?", "Monitoring": { "ApiKey": "", "Address": "http://aspire-dashboard-service.aspire.svc.cluster.local:18889", - "ServiceName": "LiteCharms.LeadGenerator" + "ServiceName": "MidrandBooks.DEV" }, + "EmailProcessorCron": "0 */5 * * * ?", "Logging": { "LogLevel": { "Default": "Information", diff --git a/litecharms-scheduler-uat.yml b/litecharms-scheduler-uat.yml index 6e8d87c..63a7dc7 100644 --- a/litecharms-scheduler-uat.yml +++ b/litecharms-scheduler-uat.yml @@ -18,6 +18,11 @@ data: Email__Port: "465" Email__UseSsl: "true" EmailProcessorCron: "0 */5 * * * ?" + HasherSettings__MinHashLength: "11" + BookshopS3Settings__ServiceUrl: "http://garage.garage.svc.cluster.local:3900" + BookshopS3Settings__Region: "garage" + BookshopS3Settings__BucketName: "bookshop" + BookshopS3Settings__CdnBaseUrl: "https://bookshop.cdn.khongisa.co.za" --- apiVersion: v1 kind: Secret @@ -31,6 +36,10 @@ data: discord-webhook: aHR0cHM6Ly9kaXNjb3JkLmNvbS9hcGkvd2ViaG9va3MvMTUwMDIzMzEyOTYwNzAzNjk3MC9KYzc5endwMjlxYWpLbmoyYkR3cm5GR0RJci11ZGIyV2JIUDZTYjdpT0hCTWpQSUY3Vkw5eUVHTkJUSXpSOVVWVzI0bQ== aspire-apikey: bWMzRzYzSzJqNVpPRXNpMEFqTW9qTFRYbTFLRVpGY3R6SUlqU3dEaVRHdXQ4cUdTa1B1V3d4R1AxUmJzY0pVbw== email-password: JFpTLWVJQGlYbTVNUCRhfg== + hasher-salt: VEdsbmFIUWdRMmhoY20xekxDQk5hV1J5WVc1a1FtOXZhM01nYldGclpTQnNiM1J6SUc5bUlHMXZibVY1SUdGdVpDQmhjbVVnWVNCemRXTmpaWE56Wm5Wc0lIWnBjbUZzSUhOMGIzSjVJR2x1SUZOdmRYUm9JRUZtY21sallRPT0= + hasher-payfastpassphrase: OUdBSVIwdFdwaFgwcU8= + bookshop-s3-accesskey: R0s1MTRkMmNlOGRjNjkyMzdhMDVjMDFlZWY= + bookshop-s3-secretkey: ZWFhZmVkYTFhZWQ0MDllY2ZlNjA3MTRlY2RhNTQ5YjgyYmRmNWEzZGFmOWYxOGRkNjFmNjZiNDk3M2E2NDgyZQ== --- apiVersion: v1 kind: Service @@ -75,7 +84,37 @@ spec: envFrom: - configMapRef: name: scheduler-config - env: + env: + - name: BookshopS3Settings__AccessKey + valueFrom: + secretKeyRef: + name: scheduler-secrets + key: bookshop-s3-accesskey + - name: BookshopS3Settings__SecretKey + valueFrom: + secretKeyRef: + name: scheduler-secrets + key: bookshop-s3-secretkey + - name: HasherSettings__Salt + valueFrom: + secretKeyRef: + name: scheduler-secrets + key: hasher-salt + - name: HasherSettings__PayfastPassphrase + valueFrom: + secretKeyRef: + name: scheduler-secrets + key: hasher-payfastpassphrase + - name: ConnectionStrings__PostgresMidrandBooks + valueFrom: + secretKeyRef: + name: scheduler-secrets + key: connection-string + - name: Monitoring__ApiKey + valueFrom: + secretKeyRef: + name: scheduler-secrets + key: aspire-apikey - name: Email__Credentials__Password valueFrom: secretKeyRef: @@ -85,12 +124,7 @@ spec: valueFrom: secretKeyRef: name: scheduler-secrets - key: connection-string-quartz - - name: ConnectionStrings__PostgresShop - valueFrom: - secretKeyRef: - name: scheduler-secrets - key: connection-string + key: connection-string-quartz - name: ConnectionStrings__DiscordShop valueFrom: secretKeyRef: