mirror of
https://github.com/ncblakely/GiantsTools
synced 2024-11-21 21:55:38 +01:00
Fix heartbeats being ignored.
This commit is contained in:
parent
e44d685d55
commit
c6c9b6f4f9
@ -21,6 +21,8 @@
|
|||||||
private readonly TimeSpan timeoutPeriod;
|
private readonly TimeSpan timeoutPeriod;
|
||||||
private CosmosDbClient client;
|
private CosmosDbClient client;
|
||||||
|
|
||||||
|
private const int ServerRefreshIntervalInMinutes = 1;
|
||||||
|
|
||||||
public CosmosDbServerRegistryStore(
|
public CosmosDbServerRegistryStore(
|
||||||
ILogger<CosmosDbServerRegistryStore> logger,
|
ILogger<CosmosDbServerRegistryStore> logger,
|
||||||
IConfiguration configuration,
|
IConfiguration configuration,
|
||||||
@ -104,7 +106,12 @@
|
|||||||
|
|
||||||
if (allServerInfo.ContainsKey(serverInfo.HostIpAddress))
|
if (allServerInfo.ContainsKey(serverInfo.HostIpAddress))
|
||||||
{
|
{
|
||||||
if (allServerInfo[serverInfo.HostIpAddress].Equals(serverInfo))
|
ServerInfo existingServerInfo = allServerInfo[serverInfo.HostIpAddress];
|
||||||
|
|
||||||
|
// DDOS protection: skip write to Cosmos if parameters have not changed,
|
||||||
|
// or it's not been long enough.
|
||||||
|
if (existingServerInfo.Equals(serverInfo)
|
||||||
|
&& Math.Abs((existingServerInfo.LastHeartbeat - serverInfo.LastHeartbeat).TotalMinutes) < ServerRefreshIntervalInMinutes)
|
||||||
{
|
{
|
||||||
this.logger.LogInformation("State for {IPAddress} is unchanged. Skipping write to store.", serverInfo.HostIpAddress);
|
this.logger.LogInformation("State for {IPAddress} is unchanged. Skipping write to store.", serverInfo.HostIpAddress);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user