public List <IDaemon> GetList(DaemonType type) { return(daemons .Select(d => d.Value) .Where(d => d.Type == type) .ToList()); }
public void Run(DaemonType type, int count) { for (var i = 0; i < count; i++) { var daemon = daemonFactory.New(type); daemon.Run(); daemons[daemon.Id] = daemon; } }
public IDaemon New(DaemonType type) { switch (type) { case DaemonType.Parser: return(new ParserDaemon(queueApi, sitesApi)); case DaemonType.Analyzer: return(new AnalyzerDaemon(queueApi, sitesApi, analyzerProviders)); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
public async Task Stop(DaemonType type, int count) { var s = 0; //Удаляем сначала простаивающих демонов foreach (var daemon in daemons) { var d = daemon.Value; if (d.Type != type) { continue; } if (s >= count) { return; } if (d.Status == DaemonConstants.IdleStatus) { await d.Stop(); daemons.Remove(d.Id, out _); ++s; } } foreach (var daemon in daemons) { var d = daemon.Value; if (d.Type != type) { continue; } if (s >= count) { return; } await d.Stop(); daemons.Remove(d.Id, out _); ++s; } }
public async Task <object> StopDaemon([FromRoute] DaemonType type) { await daemonsApi.Stop(type, 1); return(true); }
public object RunDaemon([FromRoute] DaemonType type) { daemonsApi.Run(type, 1); return(true); }