forked from admin/VolcanicAgenticCore
Each chat's jobs live in <workspace>/.volcanic/scheduler/jobs.json. On start the scheduler loads every chat's file, moves the retired shared <agentDir>/scheduler/jobs.json into them and renames it .migrated-<ts>. A VolcanicSecretary jobs.json (bare array) in a chat's folder is converted in place for that chat; the original is kept as .secretary-<ts>. Also adds the VolcanicSecretary data migration plan.
18 lines
836 B
C#
18 lines
836 B
C#
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using Volcanic.AgenticCore.Extensions.Scheduler;
|
|
|
|
namespace Volcanic.AgenticCore.Telegram.Scheduling;
|
|
|
|
/// <summary>Starts the scheduler with the Telegram delivery (registered after <c>PollingService</c>) and stops it on shutdown.</summary>
|
|
public sealed class SchedulerHostedService(JobScheduler scheduler, TelegramJobDelivery delivery, ILogger<SchedulerHostedService> logger) : IHostedService
|
|
{
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
await scheduler.StartAsync(delivery, cancellationToken).ConfigureAwait(false);
|
|
logger.LogInformation("Scheduler started with {Count} job(s)", scheduler.Count);
|
|
}
|
|
|
|
public Task StopAsync(CancellationToken cancellationToken) => scheduler.StopAsync(cancellationToken);
|
|
}
|