public ImageClassifierWorkerPool(IImageClassifierFactory factory, ImageClassifierConfiguration configuration, int workersAmount) { _roundRobinCounter = 0; _workers = new List <IImageClassifierWorker>(); for (var i = 0; i < workersAmount; ++i) { _workers.Add(new ImageClassifierWorker(factory.GetClassifier(configuration))); } }
public ImageClassifierService(ILogger <ImageClassifierService> logger, IImageClassifierFactory factory, IConfiguration configuration) { var serviceConfiguration = configuration.GetSection("ImageClassifierService") .Get <ImageClassifierServiceConfiguration>(); _cancellationTokenSource = new CancellationTokenSource(); _logger = logger; _namedWorkerPools = new Dictionary <string, ImageClassifierWorkerPool>(); foreach (var classifierConfiguration in serviceConfiguration.ImageClassifierConfigurations) { try { _namedWorkerPools.Add(classifierConfiguration.ClassifierType, new ImageClassifierWorkerPool(factory, classifierConfiguration, serviceConfiguration.WorkersPerModel)); } catch (UnknownClassifierTypeException e) { _logger.LogError(e.Message); } } }