Skip to content

Commit

Permalink
Don't require name on typed jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsmith committed Jul 26, 2024
1 parent 958435a commit 52fd16d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Foundatio.Extensions.Hosting/Jobs/JobHostExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ public static IServiceCollection AddCronJob(this IServiceCollection services, Ac
return services.AddCronJob(jobOptionsBuilder.Target);
}

public static IServiceCollection AddCronJob<T>(this IServiceCollection services, string name, string cronSchedule, Action<ScheduledJobOptionsBuilder> configureJobOptions = null) where T : class, IJob
public static IServiceCollection AddCronJob<T>(this IServiceCollection services, string cronSchedule, Action<ScheduledJobOptionsBuilder> configureJobOptions = null) where T : class, IJob
{
services.AddTransient<T>();
var jobOptionsBuilder = new ScheduledJobOptionsBuilder();
jobOptionsBuilder.Name(name).CronSchedule(cronSchedule).JobFactory(sp => sp.GetRequiredService<T>());
jobOptionsBuilder.Name(typeof(T).FullName).CronSchedule(cronSchedule).JobFactory(sp => sp.GetRequiredService<T>());
configureJobOptions?.Invoke(jobOptionsBuilder);
return services.AddCronJob(jobOptionsBuilder.Target);
}
Expand Down

0 comments on commit 52fd16d

Please sign in to comment.