예제 #1
0
        private IList <IMessageWorker> CreateWorkers()
        {
            var workers = new List <IMessageWorker>();

            int count = _configuration.WorkerCount;

            // limit worker count to 1 to 25
            count = Math.Max(1, count);
            count = Math.Min(25, count);

            for (int i = 0; i < count; i++)
            {
                string name   = $"{_configuration.Name}-Worker-{i + 1:00}";
                var    worker = new MessageWorker(this, name);

                _logger.Trace().Message("Created worker '{0}'.", worker.Name).Write();
                workers.Add(worker);
            }

            // add health work
            string healthName   = $"{_configuration.Name}-Worker-Health";
            var    healthWorker = new HealthWorker(this, healthName);

            workers.Add(healthWorker);

            return(workers);
        }
        private IList<IMessageWorker> CreateWorkers()
        {
            var workers = new List<IMessageWorker>();

            int count = _configuration.WorkerCount;

            // limit worker count to 1 to 25
            count = Math.Max(1, count);
            count = Math.Min(25, count);

            for (int i = 0; i < count; i++)
            {
                string name = string.Format("{0}-Worker-{1:00}", _configuration.Name, i + 1);
                var worker = new MessageWorker(this, name);

                Logger.Trace().Message("Created worker '{0}'.", worker.Name).Write();
                workers.Add(worker);
            }

            // add health work 
            string healthName = string.Format("{0}-Worker-Health", _configuration.Name);
            var healthWorker = new HealthWorker(this, healthName);
            workers.Add(healthWorker);

            return workers;
        }