private IEnumerable <IServerSupervisor> GetCommonSupervisors() { var stateMachineFactory = new StateMachineFactory(_storage); var sharedWorkerContext = new SharedWorkerContext( _serverId, _options.Queues, _storage, new JobPerformanceProcess(), JobActivator.Current, stateMachineFactory); yield return(new ServerSupervisor(new WorkerManager(sharedWorkerContext, _options.WorkerCount))); yield return(new ServerSupervisor(new ServerHeartbeat(_storage, _serverId))); yield return(new ServerSupervisor(new ServerWatchdog(_storage))); yield return(new ServerSupervisor( new SchedulePoller(_storage, stateMachineFactory, _options.SchedulePollingInterval))); yield return(new ServerSupervisor( new RecurringJobScheduler( _storage, new BackgroundJobClient(_storage, stateMachineFactory), new UtcNowDateTimeProvider()))); }
private IEnumerable <IServerComponent> GetCommonComponents() { var stateMachineFactory = new StateMachineFactory(_storage); var sharedWorkerContext = new SharedWorkerContext( _serverId, _options.Queues, _storage, new JobPerformanceProcess(), JobActivator.Current, stateMachineFactory); yield return(new WorkerManager(sharedWorkerContext, _options.WorkerCount)); 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(), new EveryMinuteThrottler())); }
public WorkerManagerFacts() { _sharedContext = new SharedWorkerContext( "server", new[] { "default" }, new Mock <JobStorage>().Object, new Mock <IJobPerformanceProcess>().Object, new Mock <JobActivator>().Object, new Mock <IStateMachineFactory>().Object); _workerSupervisors = new[] { new Mock <IServerSupervisor>(), new Mock <IServerSupervisor>() }; _manager = new Mock <WorkerManager>( _sharedContext, WorkerCount); _manager.Setup(x => x.CreateWorkerSupervisor(It.IsNotNull <WorkerContext>())) .Returns((WorkerContext context) => _workerSupervisors[context.WorkerNumber - 1].Object); _cts = new CancellationTokenSource(); _cts.Cancel(); }
public void CopyCtor_CorrectlyInitializes_AllProperties() { var context = CreateContext(); var contextCopy = new SharedWorkerContext(context); Assert.Equal(context.ServerId, contextCopy.ServerId); Assert.Same(context.Queues, contextCopy.Queues); Assert.Same(context.Storage, contextCopy.Storage); Assert.Same(context.PerformanceProcess, contextCopy.PerformanceProcess); Assert.Same(context.Activator, contextCopy.Activator); Assert.Same(context.StateMachineFactory, contextCopy.StateMachineFactory); }