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;
        }
예제 #2
0
        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;
        }
예제 #3
0
        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();
        }
예제 #4
0
 /// <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;
 }
예제 #5
0
        /// <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();
        }
예제 #6
0
 /// <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)
 {
 }
예제 #7
0
 /// <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)
 {
 }
예제 #8
0
 public void UseStorage(JobStorage storage)
 {
     Storage = storage;
 }
 public static void UseServer(
     this IBootstrapperConfiguration configuration,
     JobStorage storage,
     BackgroundJobServerOptions options)
 {
     configuration.UseServer(() => new BackgroundJobServer(options, storage));
 }
예제 #10
0
 public RecurringJobManager([NotNull] JobStorage storage, [NotNull] IBackgroundJobFactory factory)
     : this(storage, factory, new DefaultTimeZoneResolver())
 {
 }
예제 #11
0
 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())
 {
 }
예제 #13
0
 public BackgroundJobClient(JobStorage storage, IStateMachineFactory stateMachineFactory)
     : this(storage, stateMachineFactory, DefaultJobCreationProcess.Instance)
 {
 }
예제 #14
0
 public void UseStorage(JobStorage storage)
 {
     Storage = storage;
 }
예제 #15
0
 /// <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))
 {
 }
예제 #16
0
 public RecurringJobManager([NotNull] JobStorage storage)
     : this(storage, new BackgroundJobFactory())
 {
 }
예제 #17
0
 /// <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)
 {
 }
예제 #18
0
        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());
        }
예제 #19
0
 /// <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>())
 {
 }
예제 #20
0
 public RecurringJobManager([NotNull] JobStorage storage)
     : this(storage, new BackgroundJobClient(storage))
 {
 }
예제 #21
0
 /// <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;
 }
예제 #22
0
 /// <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))
 {
 }
예제 #23
0
 public BackgroundJobClient(JobStorage storage, IStateMachineFactory stateMachineFactory)
     : this(storage, stateMachineFactory, JobCreationProcess.Instance)
 {
 }
예제 #24
0
 public RecurringJobManager([NotNull] JobStorage storage)
     : this(storage, JobFilterProviders.Providers)
 {
 }
예제 #25
0
 public RecurringJobManager([NotNull] JobStorage storage, [NotNull] IJobFilterProvider filterProvider)
     : this(storage, filterProvider, new DefaultTimeZoneResolver())
 {
 }
예제 #26
0
 /// <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))
 {
 }