public static (BackgroundJobServer server, IRecurringJobManager recurringJobManager, IBackgroundJobClient backgroundJobClient) StartHangfireServer( string tenantId, string serverName, string connectionString, IApplicationLifetime applicationLifetime, IJobFilterProvider jobFilters, MultitenantContainer mtc, IBackgroundJobFactory backgroundJobFactory, IBackgroundJobPerformer backgroundJobPerformer, IBackgroundJobStateChanger backgroundJobStateChanger, IBackgroundProcess[] additionalProcesses ) { var tenantJobActivator = new AspNetCoreMultiTenantJobActivator(mtc, tenantId); return(HangfireHelper.StartHangfireServer( serverName, connectionString, applicationLifetime, jobFilters, tenantJobActivator, backgroundJobFactory, backgroundJobPerformer, backgroundJobStateChanger, additionalProcesses)); }
public static (BackgroundJobServer server, IRecurringJobManager recurringJobManager, IBackgroundJobClient backgroundJobClient) StartHangfireServer( string serverName, string connectionString, IApplicationLifetime applicationLifetime, IJobFilterProvider jobFilters, JobActivator jobActivator, IBackgroundJobFactory backgroundJobFactory, IBackgroundJobPerformer backgroundJobPerformer, IBackgroundJobStateChanger backgroundJobStateChanger, IBackgroundProcess[] additionalProcesses ) { var options = new BackgroundJobServerOptions { ServerName = serverName, Queues = new string[] { serverName, "default" } }; return(StartHangfireServer( options, connectionString, applicationLifetime, jobFilters, jobActivator, backgroundJobFactory, backgroundJobPerformer, backgroundJobStateChanger, additionalProcesses )); }
public AppTenantsInitializer( AppTenantsContext context, IConfiguration configuration, IHostingEnvironment environment, IApplicationLifetime applicationLifetime, IJobFilterProvider jobFilters, MultitenantContainer multiTenantContainer, IBackgroundJobFactory backgroundJobFactory, IBackgroundJobPerformer backgroundJobPerformer, IBackgroundJobStateChanger backgroundJobStateChanger, IBackgroundProcess[] additionalProcesses, ITenantConfiguration[] tenantConfigurations) { _context = context; _configuration = configuration; _environment = environment; _applicationLifetime = applicationLifetime; _jobFilters = jobFilters; _multiTenantContainer = multiTenantContainer; _backgroundJobFactory = backgroundJobFactory; _backgroundJobPerformer = backgroundJobPerformer; _backgroundJobStateChanger = backgroundJobStateChanger; _additionalProcesses = additionalProcesses; _tenantConfigurations = tenantConfigurations; }
public RecurringJobManager( [NotNull] JobStorage storage, [NotNull] IJobFilterProvider filterProvider, [NotNull] ITimeZoneResolver timeZoneResolver) : this(storage, filterProvider, timeZoneResolver, () => DateTime.UtcNow) { }
public BackgroundJobPerformer( [NotNull] IJobFilterProvider filterProvider, [NotNull] JobActivator activator, [CanBeNull] TaskScheduler taskScheduler) : this(filterProvider, new CoreBackgroundJobPerformer(activator, taskScheduler)) { }
public RecurringJobManager( [NotNull] JobStorage storage, [NotNull] IJobFilterProvider filterProvider, [NotNull] ITimeZoneResolver timeZoneResolver, [NotNull] Func <DateTime> nowFactory) : this(storage, new BackgroundJobFactory(filterProvider), timeZoneResolver, nowFactory) { }
internal BackgroundJobStateChanger([NotNull] IJobFilterProvider filterProvider, [NotNull] IStateMachine stateMachine) { if (stateMachine == null) { throw new ArgumentNullException(nameof(stateMachine)); } _stateMachine = new StateMachine(filterProvider, stateMachine); }
internal BackgroundJobPerformer( [NotNull] IJobFilterProvider filterProvider, [NotNull] IBackgroundJobPerformer innerPerformer) { if (filterProvider == null) throw new ArgumentNullException(nameof(filterProvider)); if (innerPerformer == null) throw new ArgumentNullException(nameof(innerPerformer)); _filterProvider = filterProvider; _innerPerformer = innerPerformer; }
internal StateMachine( [NotNull] IJobFilterProvider filterProvider, [NotNull] IStateMachine innerStateMachine) { if (filterProvider == null) throw new ArgumentNullException(nameof(filterProvider)); if (innerStateMachine == null) throw new ArgumentNullException(nameof(innerStateMachine)); _filterProvider = filterProvider; _innerStateMachine = innerStateMachine; }
internal BackgroundJobFactory( [NotNull] IJobFilterProvider filterProvider, [NotNull] IBackgroundJobFactory innerFactory) { if (filterProvider == null) throw new ArgumentNullException(nameof(filterProvider)); if (innerFactory == null) throw new ArgumentNullException(nameof(innerFactory)); _filterProvider = filterProvider; _innerFactory = innerFactory; }
public BackgroundJobServer( [NotNull] BackgroundJobServerOptions options, [NotNull] JobStorage storage, [NotNull] IEnumerable <IBackgroundProcess> additionalProcesses, [CanBeNull] IJobFilterProvider filterProvider, [CanBeNull] JobActivator activator, [CanBeNull] IBackgroundJobFactory factory, [CanBeNull] IBackgroundJobPerformer performer, [CanBeNull] IBackgroundJobStateChanger stateChanger) { if (storage == null) { throw new ArgumentNullException(nameof(storage)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (additionalProcesses == null) { throw new ArgumentNullException(nameof(additionalProcesses)); } _options = options; var processes = new List <IBackgroundProcessDispatcherBuilder>(); processes.AddRange(GetRequiredProcesses(filterProvider, activator, factory, performer, stateChanger)); processes.AddRange(additionalProcesses.Select(x => x.UseBackgroundPool(1))); var properties = new Dictionary <string, object> { { "Queues", options.Queues }, { "WorkerCount", options.WorkerCount } }; _logger.Info($"Starting Hangfire Server using job storage: '{storage}'"); storage.WriteOptionsToLog(_logger); _logger.Info("Using the following options for Hangfire Server:\r\n" + $" Worker count: {options.WorkerCount}\r\n" + $" Listening queues: {String.Join(", ", options.Queues.Select(x => "'" + x + "'"))}\r\n" + $" Shutdown timeout: {options.ShutdownTimeout}\r\n" + $" Schedule polling interval: {options.SchedulePollingInterval}"); _processingServer = new BackgroundProcessingServer( storage, processes, properties, GetProcessingServerOptions()); }
public AsyncBackgroundJobPerformer([NotNull] IJobFilterProvider filterProvider, [NotNull] IAsyncBackgroundJobPerformer innerPerformer) { if (filterProvider == null) { throw new ArgumentNullException(nameof(filterProvider)); } if (innerPerformer == null) { throw new ArgumentNullException(nameof(innerPerformer)); } _filterProvider = filterProvider; _innerPerformer = innerPerformer; }
public CoreBackgroundJobPerformer( [NotNull] JobActivator activator, [NotNull] IJobFilterProvider filterProvider) { if (activator == null) { throw new ArgumentNullException("activator"); } if (filterProvider == null) { throw new ArgumentNullException("filterProvider"); } _activator = activator; _filterProvider = filterProvider; }
internal BackgroundJobPerformer( [NotNull] IJobFilterProvider filterProvider, [NotNull] IBackgroundJobPerformer innerPerformer) { if (filterProvider == null) { throw new ArgumentNullException("filterProvider"); } if (innerPerformer == null) { throw new ArgumentNullException("innerPerformer"); } _filterProvider = filterProvider; _innerPerformer = innerPerformer; }
internal BackgroundJobFactory( [NotNull] IJobFilterProvider filterProvider, [NotNull] IBackgroundJobFactory innerFactory) { if (filterProvider == null) { throw new ArgumentNullException(nameof(filterProvider)); } if (innerFactory == null) { throw new ArgumentNullException(nameof(innerFactory)); } _filterProvider = filterProvider; _innerFactory = innerFactory; }
internal StateMachine( [NotNull] IJobFilterProvider filterProvider, [NotNull] IStateMachine innerStateMachine) { if (filterProvider == null) { throw new ArgumentNullException(nameof(filterProvider)); } if (innerStateMachine == null) { throw new ArgumentNullException(nameof(innerStateMachine)); } _filterProvider = filterProvider; _innerStateMachine = innerStateMachine; }
public static (BackgroundJobServer server, IRecurringJobManager recurringJobManager, IBackgroundJobClient backgroundJobClient) StartHangfireServer( BackgroundJobServerOptions options, string connectionString, IApplicationLifetime applicationLifetime, IJobFilterProvider jobFilters, JobActivator jobActivator, IBackgroundJobFactory backgroundJobFactory, IBackgroundJobPerformer backgroundJobPerformer, IBackgroundJobStateChanger backgroundJobStateChanger, IBackgroundProcess[] additionalProcesses ) { JobStorage storage; if (string.IsNullOrWhiteSpace(connectionString)) { storage = new MemoryStorage(); } else if (ConnectionStringHelper.IsSQLite(connectionString)) { storage = new SQLiteStorage(connectionString); } else { storage = new SqlServerStorage(connectionString); } var server = new BackgroundJobServer(options, storage, additionalProcesses, options.FilterProvider ?? jobFilters, options.Activator ?? jobActivator, backgroundJobFactory, backgroundJobPerformer, backgroundJobStateChanger); applicationLifetime.ApplicationStopping.Register(() => server.SendStop()); applicationLifetime.ApplicationStopped.Register(() => server.Dispose()); var recurringJobManager = new RecurringJobManager(storage, backgroundJobFactory); var backgroundJobClient = new BackgroundJobClient(storage, backgroundJobFactory, backgroundJobStateChanger); return(server, recurringJobManager, backgroundJobClient); }
private IEnumerable <IBackgroundProcessDispatcherBuilder> GetRequiredProcesses( [CanBeNull] IJobFilterProvider filterProvider, [CanBeNull] JobActivator activator, [CanBeNull] IBackgroundJobFactory factory, [CanBeNull] IBackgroundJobPerformer performer, [CanBeNull] IBackgroundJobStateChanger stateChanger) { var processes = new List <IBackgroundProcessDispatcherBuilder>(); var timeZoneResolver = _options.TimeZoneResolver ?? new DefaultTimeZoneResolver(); if (factory == null && performer == null && stateChanger == null) { filterProvider = filterProvider ?? _options.FilterProvider ?? JobFilterProviders.Providers; activator = activator ?? _options.Activator ?? JobActivator.Current; factory = new BackgroundJobFactory(filterProvider); performer = new BackgroundJobPerformer(filterProvider, activator, _options.TaskScheduler); stateChanger = new BackgroundJobStateChanger(filterProvider); } else { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } if (performer == null) { throw new ArgumentNullException(nameof(performer)); } if (stateChanger == null) { throw new ArgumentNullException(nameof(stateChanger)); } } processes.Add(new Worker(_options.Queues, performer, stateChanger).UseBackgroundPool(_options.WorkerCount)); processes.Add(new DelayedJobScheduler(_options.SchedulePollingInterval, stateChanger).UseBackgroundPool(1)); processes.Add(new RecurringJobScheduler(factory, _options.SchedulePollingInterval, timeZoneResolver).UseBackgroundPool(1)); return(processes); }
public HangfireServer( BackgroundJobServerOptions options, JobStorage jobStorage, IEnumerable <IBackgroundProcess> backgroundProcesses, IBackgroundJobFactory jobFactory, IBackgroundJobPerformer jobPerformer, IBackgroundJobStateChanger jobStateChanger, ILogger <HangfireServer> logger, IJobFilterProvider jobFilterProvider = default, JobActivator activator = default ) { _options = options; _jobStorage = jobStorage; _backgroundProcesses = backgroundProcesses; _jobFactory = jobFactory; _jobPerformer = jobPerformer; _jobStateChanger = jobStateChanger; _jobFilterProvider = options.FilterProvider ?? jobFilterProvider; _activator = options.Activator ?? activator; _logger = logger; }
private IEnumerable <IBackgroundProcess> GetRequiredProcesses( [NotNull] IJobFilterProvider filterProvider, [NotNull] JobActivator activator, [CanBeNull] IBackgroundJobFactory factory, [CanBeNull] IBackgroundJobPerformer performer, [CanBeNull] IBackgroundJobStateChanger stateChanger) { var processes = new List <IBackgroundProcess>(); factory = factory ?? new BackgroundJobFactory(filterProvider); performer = performer ?? new BackgroundJobPerformer(filterProvider, activator); stateChanger = stateChanger ?? new BackgroundJobStateChanger(filterProvider); for (var i = 0; i < _options.WorkerCount; i++) { processes.Add(new Worker(_options.Queues, performer, stateChanger)); } processes.Add(new DelayedJobScheduler(_options.SchedulePollingInterval, stateChanger)); processes.Add(new RecurringJobScheduler(factory)); return(processes); }
public BackgroundJobClientWithContext([NotNull] JobStorage storage, [NotNull] IJobFilterProvider filterProvider) : this(storage, new BackgroundJobFactory(filterProvider), new BackgroundJobStateChanger(filterProvider)) { }
public StateMachine([NotNull] IJobFilterProvider filterProvider) : this(filterProvider, new CoreStateMachine()) { }
public RecurringJobManager([NotNull] JobStorage storage, [NotNull] IJobFilterProvider filterProvider) : this(storage, filterProvider, new DefaultTimeZoneResolver()) { }
public BackgroundJobStateChanger([NotNull] IJobFilterProvider filterProvider) : this(filterProvider, new CoreStateMachine()) { }
public SpecifyQueueBackgroundJobClient([NotNull] JobStorage storage, [NotNull] IJobFilterProvider filterProvider) : this(storage, new BackgroundJobFactory(filterProvider), new BackgroundJobStateChanger(filterProvider)) { }
public BackgroundJobPerformer( [NotNull] IJobFilterProvider filterProvider, [NotNull] JobActivator activator) : this(filterProvider, new CoreBackgroundJobPerformer(activator, filterProvider)) { }
public BackgroundJobFactory([NotNull] IJobFilterProvider filterProvider) : this(filterProvider, new CoreBackgroundJobFactory(new StateMachine(filterProvider))) { }
public BackgroundJobPerformer([NotNull] IJobFilterProvider filterProvider) : this(filterProvider, new CoreBackgroundJobPerformer()) { }
public BackgroundJobPerformer([NotNull] IJobFilterProvider filterProvider) : this(filterProvider, JobActivator.Current) { }
public BackgroundJobPerformer( [NotNull] IJobFilterProvider filterProvider, [NotNull] JobActivator activator) : this(filterProvider, activator, TaskScheduler.Default) { }