books/backend/Books.Api/Infrastructure/HangfireScheduler.cs
Nicolaj Hartmann 66f6fa138d Initial commit: Books accounting system with EventFlow CQRS
Backend (.NET 10):
- EventFlow CQRS/Event Sourcing with PostgreSQL
- GraphQL.NET API with mutations and queries
- Custom ReadModelSqlGenerator for snake_case PostgreSQL columns
- Hangfire for background job processing
- Integration tests with isolated test databases

Frontend (React/Vite):
- Initial project structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 02:52:30 +01:00

27 lines
772 B
C#

using System.Linq.Expressions;
using Hangfire;
namespace Books.Api.Infrastructure;
public class HangfireScheduler(IBackgroundJobClient jobClient, IRecurringJobManager recurringJobManager) : IScheduler
{
public void EnqueueJob<T>(Expression<Func<T, Task>> methodCall)
{
jobClient.Enqueue(methodCall);
}
public void EnqueueJob<T>(Expression<Func<T, Task>> methodCall, TimeSpan delay)
{
jobClient.Schedule(methodCall, delay);
}
public void EnqueueJob(Expression<Func<Task>> methodCall)
{
jobClient.Enqueue(methodCall);
}
public void AddOrUpdateScheduledJob<T>(string title, Expression<Func<T?, Task>> methodCall, string cron)
{
recurringJobManager.AddOrUpdate(title, methodCall, cron);
}
}