Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
agile.zhou committed May 26, 2024
1 parent b98ad79 commit 6e870a7
Showing 1 changed file with 3 additions and 38 deletions.
41 changes: 3 additions & 38 deletions src/AgileConfig.Server.Apisite/Metrics/MeterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ public MeterService(IServiceScopeFactory sf)
public void Start()
{
_ = StartCheckAppCountAsync();
_ = StartCheckConfigCountAsync();
_ = StartCheckNodeCountAsync();
_ = StartCheckNodeCountAsync();
_ = StartCheckServiceCountAsync();
}

private Task StartCheckAppCountAsync()
Expand All @@ -84,29 +80,12 @@ private Task StartCheckAppCountAsync()
while (true)
{
_appCount = await _appService.CountEnabledAppsAsync();
await Task.Delay(1000 * _checkInterval);
}
});
}
private Task StartCheckConfigCountAsync()
{
return Task.Run(async () =>
{
while (true)
{
_configCount = await _configService.CountEnabledConfigsAsync();
await Task.Delay(1000 * _checkInterval);
}
});
}
private Task StartCheckNodeCountAsync()
{
return Task.Run(async () =>
{
while (true)
{
var services = await _serviceInfoService.GetAllServiceInfoAsync();
_serviceCount = services.Count;
var nodes = await _serverNodeService.GetAllNodesAsync();
_serverNodeCount = nodes.Count;
Expand All @@ -125,19 +104,5 @@ private Task StartCheckNodeCountAsync()
}
});
}

private Task StartCheckServiceCountAsync()
{
return Task.Run(async () =>
{
while (true)
{
var services = await _serviceInfoService.GetAllServiceInfoAsync();
_serviceCount = services.Count;
await Task.Delay(1000 * _checkInterval);
}
});
}
}
}

0 comments on commit 6e870a7

Please sign in to comment.