internal int DetermineWorkerCount(IMonitoringApi monitor, StoredConfiguration configuration, WorkerDeterminerOptions options) { var goal = configuration.GoalWorkerCount ?? options.DefaultGoalWorkerCount; if (goal > options.MaximumGoalWorkerCount) { goal = options.MaximumGoalWorkerCount; } var serverCount = _serverCountDeterminer.DetermineServerCount(monitor, options); var workerCount = Convert.ToInt32(Math.Ceiling(goal / (decimal)serverCount)); if (configuration.MaxWorkersPerServer.HasValue) { if (workerCount > configuration.MaxWorkersPerServer.Value) { workerCount = configuration.MaxWorkersPerServer.Value; } } if (workerCount < options.MinimumWorkerCount) { workerCount = options.MinimumWorkerCount; } return(workerCount); }
private int readServerCount(IMonitoringApi monitor, WorkerDeterminerOptions options) { if (options.UseServerCountSampling) { var serverCount = serverCountFromSamples(); if (serverCount.HasValue) { return(serverCount.Value); } } return(serverCountFromHangfire(monitor)); }
public int DetermineServerCount(IMonitoringApi monitor, WorkerDeterminerOptions options) { var serverCount = readServerCount(monitor, options); if (options.MinimumServerCount.HasValue) { if (serverCount < options.MinimumServerCount) { return(options.MinimumServerCount.Value); } } return(serverCount); }