public static bool Validate(WorkerConfiguration <T> configuration)
 {
     if (configuration.MaximumAllowedExecutionTime.TotalSeconds < 1)
     {
         return(false);
     }
     if (configuration.MaximumConcurrentCalls <= 0)
     {
         return(false);
     }
     if (configuration.Service is null)
     {
         return(false);
     }
     if (configuration.Area is null)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 2
0
        public WorkerInvoker(
            IJobRepository jobRepository,
            IOptions <WorkerConfiguration <TWorker> > workerConfiguration,
            ISerializer <TInput> inputSerializer,
            ISerializer <TOutput> outputSerializer,
            IJobQueue jobQueue,
            IWorkerScopeFactory scopeFactory,
            ILogger <WorkerInvoker <TWorker, TInput, TOutput> > logger)
        {
            _logger              = logger;
            _jobRepository       = jobRepository;
            _workerConfiguration = workerConfiguration.Value;
            _inputSerializer     = inputSerializer;
            _outputSerializer    = outputSerializer;
            _jobQueue            = jobQueue;
            _scopeFactory        = scopeFactory;

            _consumer            = _jobQueue.GetConsumer(CreateQueueConfiguration());
            _consumer.JobQueued += OnNewJob;
            _consumer.Error     += OnError;
        }