public Worker( [NotNull] WorkerContext context, [NotNull] JobStorage storage, [NotNull] IJobPerformanceProcess process, [NotNull] IStateMachineFactory stateMachineFactory) { if (context == null) { throw new ArgumentNullException("context"); } if (storage == null) { throw new ArgumentNullException("storage"); } if (process == null) { throw new ArgumentNullException("process"); } if (stateMachineFactory == null) { throw new ArgumentNullException("stateMachineFactory"); } _context = context; _storage = storage; _process = process; _stateMachineFactory = stateMachineFactory; }
public void CopyCtor_CorrectlyCopies_AllPropertyValues() { var context = CreateContext(); var contextCopy = new WorkerContext(context); Assert.Equal(context.WorkerNumber, contextCopy.WorkerNumber); }
internal PerformContext( WorkerContext workerContext, IStorageConnection connection, string jobId, Job job, DateTime createdAt, IJobCancellationToken cancellationToken) : base(workerContext) { if (connection == null) { throw new ArgumentNullException("connection"); } if (jobId == null) { throw new ArgumentNullException("jobId"); } if (job == null) { throw new ArgumentNullException("job"); } if (cancellationToken == null) { throw new ArgumentNullException("cancellationToken"); } Connection = connection; JobId = jobId; Job = job; CreatedAt = createdAt; CancellationToken = cancellationToken; Items = new Dictionary <string, object>(); }
internal virtual IServerSupervisor CreateWorkerSupervisor(WorkerContext context) { return(new ServerSupervisor( new AutomaticRetryServerComponentWrapper(new Worker(context)), new ServerSupervisorOptions { LowerLogVerbosity = true })); }
internal virtual IServerSupervisor CreateWorkerSupervisor(WorkerContext context) { return(new ServerSupervisor( new Worker(context), new ServerSupervisorOptions { LowerLogVerbosity = true })); }
public Worker(WorkerContext context) { if (context == null) { throw new ArgumentNullException("context"); } _context = context; }
public void CreateWorkerSupervisor_CreatesAWorkerSupervisorWithGivenParameters() { var manager = new WorkerManager(_sharedContext, WorkerCount); var context = new WorkerContext(_sharedContext, 1); var worker = manager.CreateWorkerSupervisor(context); Assert.NotNull(worker); }
public ServerJobCancellationToken( [NotNull] string jobId, [NotNull] IStorageConnection connection, [NotNull] WorkerContext workerContext, CancellationToken shutdownToken) { if (jobId == null) throw new ArgumentNullException("jobId"); if (connection == null) throw new ArgumentNullException("connection"); if (workerContext == null) throw new ArgumentNullException("workerContext"); _jobId = jobId; _shutdownToken = shutdownToken; _connection = connection; _workerContext = workerContext; }
public Worker( [NotNull] WorkerContext context, [NotNull] JobStorage storage, [NotNull] IJobPerformanceProcess process, [NotNull] IStateMachineFactory stateMachineFactory) { if (context == null) throw new ArgumentNullException("context"); if (storage == null) throw new ArgumentNullException("storage"); if (process == null) throw new ArgumentNullException("process"); if (stateMachineFactory == null) throw new ArgumentNullException("stateMachineFactory"); _context = context; _storage = storage; _process = process; _stateMachineFactory = stateMachineFactory; }
public void Execute(CancellationToken cancellationToken) { var workerSupervisors = new List<IServerSupervisor>(_workerCount); for (var i = 1; i <= _workerCount; i++) { var workerContext = new WorkerContext(_sharedContext, i); // ReSharper disable once DoNotCallOverridableMethodsInConstructor workerSupervisors.Add(CreateWorkerSupervisor(workerContext)); } using (var supervisors = new ServerSupervisorCollection(workerSupervisors)) { supervisors.Start(); cancellationToken.WaitHandle.WaitOne(); } }
public void Execute(CancellationToken cancellationToken) { var workerSupervisors = new List <IServerSupervisor>(_workerCount); for (var i = 1; i <= _workerCount; i++) { var workerContext = new WorkerContext(_sharedContext, i); // ReSharper disable once DoNotCallOverridableMethodsInConstructor workerSupervisors.Add(CreateWorkerSupervisor(workerContext)); } using (var supervisors = new ServerSupervisorCollection(workerSupervisors)) { supervisors.Start(); cancellationToken.WaitHandle.WaitOne(); } }
public ServerJobExecutionContext( [NotNull] string jobId, [NotNull] IStorageConnection connection, [NotNull] WorkerContext workerContext, CancellationToken shutdownToken) { if (jobId == null) { throw new ArgumentNullException("jobId"); } if (connection == null) { throw new ArgumentNullException("connection"); } if (workerContext == null) { throw new ArgumentNullException("workerContext"); } _jobId = jobId; _shutdownToken = shutdownToken; _connection = connection; _workerContext = workerContext; }
internal WorkerContext(WorkerContext workerContext) : this (workerContext.ServerId, workerContext.Queues, workerContext.WorkerNumber) { }
public Worker(WorkerContext context) { if (context == null) throw new ArgumentNullException("context"); _context = context; }
internal WorkerContext(WorkerContext workerContext) : this (workerContext, workerContext.WorkerNumber) { }
private IEnumerable<IServerComponent> GetCommonComponents() { var performanceProcess = new DefaultJobPerformanceProcess(JobActivator.Current); var stateMachineFactory = new StateMachineFactory(_storage); for (var i = 0; i < _options.WorkerCount; i++) { var context = new WorkerContext(_serverId, _options.Queues, i + 1); yield return new Worker(context, _storage, performanceProcess, stateMachineFactory); } yield return new ServerHeartbeat(_storage, _serverId); yield return new SchedulePoller(_storage, stateMachineFactory, _options.SchedulePollingInterval); yield return new ServerWatchdog(_storage, _options.ServerWatchdogOptions); yield return new RecurringJobScheduler( _storage, new BackgroundJobClient(_storage, stateMachineFactory), new ScheduleInstantFactory(), SchedulerResolution.Current.CreateThrottler()); }
internal WorkerContext(WorkerContext workerContext) : this(workerContext, workerContext.WorkerNumber) { }
internal WorkerContext(WorkerContext workerContext) : this(workerContext.ServerId, workerContext.Queues, workerContext.WorkerNumber) { }
internal virtual IServerSupervisor CreateWorkerSupervisor(WorkerContext context) { return new ServerSupervisor( new Worker(context), new ServerSupervisorOptions { LowerLogVerbosity = true }); }