From aef830debace7841a7cc96e8e376b6edb6c230dc Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Wed, 29 Jan 2025 06:45:49 -0600 Subject: [PATCH] remove redis dependency from CrontabEventSubscription --- .../Services/CrontabEventSubscription.cs | 20 +++++-------------- .../Infrastructures/DistributedLocker.cs | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabEventSubscription.cs b/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabEventSubscription.cs index 099b9312..17b599b6 100644 --- a/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabEventSubscription.cs +++ b/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabEventSubscription.cs @@ -21,7 +21,11 @@ public class CrontabEventSubscription : BackgroundService using (var scope = _services.CreateScope()) { - var publisher = scope.ServiceProvider.GetRequiredService(); + var publisher = scope.ServiceProvider.GetService(); + if (publisher == null) + { + return; + } var subscriber = scope.ServiceProvider.GetRequiredService(); var cron = scope.ServiceProvider.GetRequiredService(); var crons = await cron.GetCrontable(); @@ -46,19 +50,5 @@ public class CrontabEventSubscription : BackgroundService }); } } - - - /*using (var scope = _services.CreateScope()) - { - var cron = scope.ServiceProvider.GetRequiredService(); - var crons = await cron.GetCrontable(); - - - - while (!stoppingToken.IsCancellationRequested) - { - await Task.Delay(1000, stoppingToken); - } - }*/ } } diff --git a/src/Infrastructure/BotSharp.Core/Infrastructures/DistributedLocker.cs b/src/Infrastructure/BotSharp.Core/Infrastructures/DistributedLocker.cs index 0b1a9c1d..a040525f 100644 --- a/src/Infrastructure/BotSharp.Core/Infrastructures/DistributedLocker.cs +++ b/src/Infrastructure/BotSharp.Core/Infrastructures/DistributedLocker.cs @@ -24,7 +24,7 @@ public class DistributedLocker : IDistributedLocker var redis = _services.GetService(); if (redis == null) { - _logger.LogWarning($"The Redis server is experiencing issues and is not functioning as expected."); + _logger.LogInformation($"The Redis server is experiencing issues and is not functioning as expected."); await action(); return true; }