public RecurringJobManager([NotNull] JobStorage storage, [NotNull] IBackgroundJobFactory factory) { if (storage == null) throw new ArgumentNullException("storage"); if (factory == null) throw new ArgumentNullException("factory"); _storage = storage; _factory = factory; }
public RecurringJobManager([NotNull] JobStorage storage, [NotNull] IBackgroundJobClient client) { if (storage == null) throw new ArgumentNullException("storage"); if (client == null) throw new ArgumentNullException("client"); _storage = storage; _client = client; }
public BackgroundJobServer(BackgroundJobServerOptions options, JobStorage storage) { if (options == null) throw new ArgumentNullException("options"); if (storage == null) throw new ArgumentNullException("storage"); _options = options; _storage = storage; _serverId = String.Format("{0}:{1}", _options.ServerName.ToLowerInvariant(), Process.GetCurrentProcess().Id); // ReSharper disable once DoNotCallOverridableMethodsInConstructor _bootstrapSupervisor = GetBootstrapSupervisor(); }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundJobClient"/> class /// with a specified job storage and job creation process. /// </summary> /// /// <exception cref="ArgumentNullException"><paramref name="storage"/> argument is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="process"/> argument is null.</exception> public BackgroundJobClient( JobStorage storage, IStateMachineFactory stateMachineFactory, IJobCreationProcess process) { if (storage == null) throw new ArgumentNullException("storage"); if (stateMachineFactory == null) throw new ArgumentNullException("stateMachineFactory"); if (process == null) throw new ArgumentNullException("process"); _storage = storage; _stateMachineFactory = stateMachineFactory; _process = process; }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundJobServer"/> class /// with the specified options and the given storage. /// </summary> /// <param name="options">Server options</param> /// <param name="storage">The storage</param> public BackgroundJobServer(BackgroundJobServerOptions options, JobStorage storage) { if (options == null) throw new ArgumentNullException("options"); if (storage == null) throw new ArgumentNullException("storage"); _options = options; _storage = storage; _serverId = String.Format("{0}:{1}", _options.ServerName.ToLowerInvariant(), Process.GetCurrentProcess().Id); // ReSharper disable once DoNotCallOverridableMethodsInConstructor _bootstrapSupervisor = GetBootstrapSupervisor(); Logger.Info("Starting Hangfire Server"); Logger.InfoFormat("Using job storage: '{0}'.", _storage); _storage.WriteOptionsToLog(Logger); _options.WriteToLog(Logger); _bootstrapSupervisor.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundJobServer"/> class /// with default options and the given storage. /// </summary> /// <param name="storage">The storage</param> public BackgroundJobServer(JobStorage storage) : this(new BackgroundJobServerOptions(), storage) { }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundJobClient"/> /// class with the specified storage. /// </summary> /// /// <param name="storage">Job storage to use for background jobs.</param> /// /// <exception cref="ArgumentNullException"><paramref name="storage"/> is null.</exception> public BackgroundJobClient([NotNull] JobStorage storage) : this(storage, JobFilterProviders.Providers) { }
public void UseStorage(JobStorage storage) { Storage = storage; }
public static void UseServer( this IBootstrapperConfiguration configuration, JobStorage storage, BackgroundJobServerOptions options) { configuration.UseServer(() => new BackgroundJobServer(options, storage)); }
public RecurringJobManager([NotNull] JobStorage storage, [NotNull] IBackgroundJobFactory factory) : this(storage, factory, new DefaultTimeZoneResolver()) { }
public RecurringJobManager([NotNull] JobStorage storage, [NotNull] IBackgroundJobFactory factory, [NotNull] ITimeZoneResolver timeZoneResolver) : this(storage, factory, timeZoneResolver, () => DateTime.UtcNow) { }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundJobClient"/> /// class with the specified storage. /// </summary> /// /// <param name="storage">Job storage to use for background jobs.</param> /// /// <exception cref="ArgumentNullException"><paramref name="storage"/> is null.</exception> public BackgroundJobClient([NotNull] JobStorage storage) : this(storage, new BackgroundJobFactory(), new BackgroundJobStateChanger()) { }
public BackgroundJobClient(JobStorage storage, IStateMachineFactory stateMachineFactory) : this(storage, stateMachineFactory, DefaultJobCreationProcess.Instance) { }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundJobClient"/> class /// with a specified storage and the default global /// <see cref="JobCreationProcess"/> instance. /// </summary> public BackgroundJobClient(JobStorage storage) : this(storage, new StateMachineFactory(storage)) { }
public RecurringJobManager([NotNull] JobStorage storage) : this(storage, new BackgroundJobFactory()) { }
public BackgroundJobServer( [NotNull] BackgroundJobServerOptions options, [NotNull] JobStorage storage, [NotNull] IEnumerable <IBackgroundProcess> additionalProcesses, [NotNull] IJobFilterProvider filterProvider, [NotNull] 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)); } if (filterProvider == null) { throw new ArgumentNullException(nameof(filterProvider)); } if (activator == null) { throw new ArgumentNullException(nameof(activator)); } _options = options; var processes = new List <IBackgroundProcess>(); processes.AddRange(GetRequiredProcesses(filterProvider, activator, factory, performer, stateChanger)); processes.AddRange(additionalProcesses); var properties = new Dictionary <string, object> { { "Queues", options.Queues }, { "WorkerCount", options.WorkerCount } }; _logger.Info("Starting Hangfire Server"); _logger.Info($"Using job storage: '{storage}'"); storage.WriteOptionsToLog(_logger); _logger.Info("Using the following options for Hangfire Server:"); _logger.Info($" Worker count: {options.WorkerCount}"); _logger.Info($" Listening queues: {String.Join(", ", options.Queues.Select(x => "'" + x + "'"))}"); _logger.Info($" Shutdown timeout: {options.ShutdownTimeout}"); _logger.Info($" Schedule polling interval: {options.SchedulePollingInterval}"); _processingServer = new BackgroundProcessingServer( storage, processes, properties, GetProcessingServerOptions()); }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundJobServer"/> class /// with the specified options and the given storage. /// </summary> /// <param name="options">Server options</param> /// <param name="storage">The storage</param> public BackgroundJobServer([NotNull] BackgroundJobServerOptions options, [NotNull] JobStorage storage) : this(options, storage, Enumerable.Empty <IBackgroundProcess>()) { }
public RecurringJobManager([NotNull] JobStorage storage) : this(storage, new BackgroundJobClient(storage)) { }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundJobClient"/> class /// with the specified storage, background job factory and state changer. /// </summary> /// /// <param name="storage">Job storage to use for background jobs.</param> /// <param name="factory">Factory to create background jobs.</param> /// <param name="stateChanger">State changer to change states of background jobs.</param> /// /// <exception cref="ArgumentNullException"><paramref name="storage"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="factory"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="stateChanger"/> is null.</exception> public BackgroundJobClient( [NotNull] JobStorage storage, [NotNull] IBackgroundJobFactory factory, [NotNull] IBackgroundJobStateChanger stateChanger) { if (storage == null) throw new ArgumentNullException("storage"); if (factory == null) throw new ArgumentNullException("factory"); if (stateChanger == null) throw new ArgumentNullException("stateChanger"); _storage = storage; _stateChanger = stateChanger; _factory = factory; }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundJobClient"/> class /// with the specified storage and filter provider. /// </summary> /// <param name="storage">Job storage to use for background jobs.</param> /// <param name="filterProvider">Filter provider responsible to locate job filters.</param> /// <exception cref="ArgumentNullException"><paramref name="storage"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="filterProvider"/> is null.</exception> public BackgroundJobClient([NotNull] JobStorage storage, [NotNull] IJobFilterProvider filterProvider) : this(storage, new BackgroundJobFactory(filterProvider), new BackgroundJobStateChanger(filterProvider)) { }
public BackgroundJobClient(JobStorage storage, IStateMachineFactory stateMachineFactory) : this(storage, stateMachineFactory, JobCreationProcess.Instance) { }
public RecurringJobManager([NotNull] JobStorage storage) : this(storage, JobFilterProviders.Providers) { }
public RecurringJobManager([NotNull] JobStorage storage, [NotNull] IJobFilterProvider filterProvider) : this(storage, filterProvider, new DefaultTimeZoneResolver()) { }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundJobClient"/> class /// with a specified storage and the default global /// <see cref="DefaultJobCreationProcess"/> instance. /// </summary> public BackgroundJobClient(JobStorage storage) : this(storage, new StateMachineFactory(storage)) { }