Пример #1
0
 public QuartzHostedService(
     ISchedulerFactory schedulerFactory,
     QuartzHealthCheck healthCheck,
     QuartzHostedServiceOptions options)
 {
     this.schedulerFactory = schedulerFactory;
     this.healthCheck      = healthCheck;
     this.options          = options;
 }
        public static IServiceCollection AddQuartzServer(
            this IServiceCollection services,
            Action <QuartzHostedServiceOptions>?configure = null)
        {
            var check = new QuartzHealthCheck();

            services
            .AddHealthChecks()
            .AddQuartzHealthCheck <QuartzHealthCheck>("scheduler", check);

            services.AddSingleton <ISchedulerListener>(check);

            return(services.AddQuartzHostedService(configure));
        }
        public static IServiceCollection AddQuartzServer(
            this IServiceCollection services,
            Action<QuartzHostedServiceOptions>? configure = null)
        {
            #if SUPPORTS_HEALTH_CHECKS
            var check = new QuartzHealthCheck();
            services
                .AddHealthChecks()
                .AddCheck("quartz-scheduler", check);

            services.AddSingleton<ISchedulerListener>(check);
            #endif

            return services.AddQuartzHostedService(configure);
        }
Пример #4
0
        public static IServiceCollection AddQuartzServer(
            this IServiceCollection services,
            Action <QuartzHostedServiceOptions>?configure = null)
        {
            var check = new QuartzHealthCheck();

            services
            .AddHealthChecks()
            .AddQuartzHealthCheck("scheduler", check);

            return(services.AddSingleton <IHostedService>(serviceProvider =>
            {
                var scheduler = serviceProvider.GetRequiredService <ISchedulerFactory>();

                var options = new QuartzHostedServiceOptions();
                configure?.Invoke(options);

                return new QuartzHostedService(scheduler, check, options);
            }));
        }