public async Task<ServerPullData> PullAsync(MonitoringQuery query) { var server = _servers.GetOrAdd(query.Server.Id, hash => new ServerInfo()); var serverData = _serversData.GetOrAdd(query.Server.Id, hash => new InMemoryServerData()).ToList(); if(!serverData.Any()) return new ServerPullData(); var items = new List<ServerStatisticsDataItem>(); foreach (var sData in serverData) { var item = new ServerStatisticsDataItem { Name = sData.Key, Order = sData.Value.Order, CurrentValue = await sData.Value.LastValue(), CurrentValueDisplay = sData.Value.Display, Type = sData.Value.Type, Data = await sData.Value.FilterData(query) }; items.Add(item); } var result = new ServerPullData { LastPush = server.LastPush, Items = items.OrderBy(x => x.Order) }; return await Task.FromResult(result); }
public async Task InternalPush(ServerStatisticsDataItem item) { _monitoringData.Enqueue(new InMemoryTimeValue(item.CurrentValue, DateTime.UtcNow)); Order = item.Order; Display = item.CurrentValueDisplay; await Task.CompletedTask; }