Spaces:
Sleeping
Sleeping
Download src/ClipForge.Infrastructure/Services/SchedulerService.cs from clipeforge/app: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/spaces/clipeforge/app/resolve/main/src/ClipForge.Infrastructure/Services/SchedulerService.cs
- Command line
-
hf download hf://spaces/clipeforge/app/src/ClipForge.Infrastructure/Services/SchedulerService.cs
-
curl -L -o SchedulerService.cs https://huggingface.co/spaces/clipeforge/app/resolve/main/src/ClipForge.Infrastructure/Services/SchedulerService.cs
1.84 kB
| using ClipForge.Core.Interfaces.Services; | |
| using Hangfire; | |
| using Microsoft.Extensions.Logging; | |
| namespace ClipForge.Infrastructure.Services; | |
| public class SchedulerService : ISchedulerService | |
| { | |
| private readonly IRecurringJobManager _recurringJobs; | |
| private readonly IBackgroundJobClient _backgroundJobs; | |
| private readonly ILogger<SchedulerService> _logger; | |
| public SchedulerService( | |
| IBackgroundJobClient backgroundJobs, | |
| IRecurringJobManager recurringJobs, | |
| ILogger<SchedulerService> logger) | |
| { | |
| _backgroundJobs = backgroundJobs; | |
| _recurringJobs = recurringJobs; | |
| _logger = logger; | |
| } | |
| public Task ScheduleFullPipelineAsync(string niche, string platform = "tiktok", CancellationToken ct = default) | |
| { | |
| _logger.LogInformation("Scheduling full pipeline for niche '{Niche}' on {Platform}", niche, platform); | |
| // Handled directly in PipelineEndpoints via Hangfire | |
| return Task.CompletedTask; | |
| } | |
| public Task ScheduleRecurringGenerationAsync(string niche, string cronExpression, string platform = "tiktok", CancellationToken ct = default) | |
| { | |
| var jobId = $"pipeline-{niche}-{platform}".ToLowerInvariant().Replace(" ", "-"); | |
| _logger.LogInformation("Scheduling recurring pipeline '{JobId}' with cron '{Cron}'", jobId, cronExpression); | |
| _recurringJobs.AddOrUpdate<IIdeaGenerationService>( | |
| jobId, | |
| svc => svc.GenerateIdeaAsync(niche, platform, CancellationToken.None), | |
| cronExpression); | |
| return Task.CompletedTask; | |
| } | |
| public Task CancelRecurringJobAsync(string jobId, CancellationToken ct = default) | |
| { | |
| _logger.LogInformation("Cancelling recurring job '{JobId}'", jobId); | |
| _recurringJobs.RemoveIfExists(jobId); | |
| return Task.CompletedTask; | |
| } | |
| } | |