mirror of
https://github.com/ncblakely/GiantsTools
synced 2024-11-22 06:05:38 +01:00
Fix expired servers not being cleaned up.
This commit is contained in:
parent
66b9ff5704
commit
2159bbc8b9
@ -62,7 +62,9 @@
|
|||||||
{
|
{
|
||||||
List<string> expiredServers = (await this
|
List<string> expiredServers = (await this
|
||||||
.serverRegistryStore
|
.serverRegistryStore
|
||||||
.GetServerInfos(whereExpression: s => s.LastHeartbeat < (this.dateTimeProvider.UtcNow - this.timeoutPeriod)))
|
.GetServerInfos(
|
||||||
|
whereExpression: s => s.LastHeartbeat < (this.dateTimeProvider.UtcNow - this.timeoutPeriod),
|
||||||
|
includeExpired: true))
|
||||||
.Select(s => s.id)
|
.Select(s => s.id)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
public async Task<IEnumerable<ServerInfo>> GetServerInfos(
|
public async Task<IEnumerable<ServerInfo>> GetServerInfos(
|
||||||
Expression<Func<ServerInfo, bool>> whereExpression = null,
|
Expression<Func<ServerInfo, bool>> whereExpression = null,
|
||||||
|
bool includeExpired = false,
|
||||||
string partitionKey = null)
|
string partitionKey = null)
|
||||||
{
|
{
|
||||||
ConcurrentDictionary<string, ServerInfo> serverInfo = await this.memoryCache.GetOrCreateAsync(CacheKeys.ServerInfo, this.PopulateCache);
|
ConcurrentDictionary<string, ServerInfo> serverInfo = await this.memoryCache.GetOrCreateAsync(CacheKeys.ServerInfo, this.PopulateCache);
|
||||||
@ -51,12 +52,18 @@
|
|||||||
serverInfoQuery = serverInfoQuery.Where(whereExpression);
|
serverInfoQuery = serverInfoQuery.Where(whereExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
return serverInfoQuery.Where(c => c.LastHeartbeat > this.dateTimeProvider.UtcNow - this.timeoutPeriod)
|
if (!includeExpired)
|
||||||
|
{
|
||||||
|
serverInfoQuery = serverInfoQuery.Where(c => c.LastHeartbeat > this.dateTimeProvider.UtcNow - this.timeoutPeriod);
|
||||||
|
}
|
||||||
|
|
||||||
|
return serverInfoQuery
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TSelect>> GetServerInfos<TSelect>(
|
public async Task<IEnumerable<TSelect>> GetServerInfos<TSelect>(
|
||||||
Expression<Func<ServerInfo, TSelect>> selectExpression,
|
Expression<Func<ServerInfo, TSelect>> selectExpression,
|
||||||
|
bool includeExpired = false,
|
||||||
Expression<Func<ServerInfo, bool>> whereExpression = null,
|
Expression<Func<ServerInfo, bool>> whereExpression = null,
|
||||||
string partitionKey = null)
|
string partitionKey = null)
|
||||||
{
|
{
|
||||||
@ -71,7 +78,12 @@
|
|||||||
serverInfoQuery = serverInfoQuery.Where(whereExpression);
|
serverInfoQuery = serverInfoQuery.Where(whereExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
return serverInfoQuery.Where(c => c.LastHeartbeat > this.dateTimeProvider.UtcNow - this.timeoutPeriod)
|
if (!includeExpired)
|
||||||
|
{
|
||||||
|
serverInfoQuery = serverInfoQuery.Where(c => c.LastHeartbeat > this.dateTimeProvider.UtcNow - this.timeoutPeriod);
|
||||||
|
}
|
||||||
|
|
||||||
|
return serverInfoQuery
|
||||||
.Select(selectExpression)
|
.Select(selectExpression)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
|
|
||||||
Task<ServerInfo> GetServerInfo(string ipAddress);
|
Task<ServerInfo> GetServerInfo(string ipAddress);
|
||||||
|
|
||||||
Task<IEnumerable<ServerInfo>> GetServerInfos(Expression<Func<ServerInfo, bool>> whereExpression = null, string partitionKey = null);
|
Task<IEnumerable<ServerInfo>> GetServerInfos(Expression<Func<ServerInfo, bool>> whereExpression = null, bool includeExpired = false, string partitionKey = null);
|
||||||
|
|
||||||
Task<IEnumerable<TSelect>> GetServerInfos<TSelect>(
|
Task<IEnumerable<TSelect>> GetServerInfos<TSelect>(
|
||||||
Expression<Func<ServerInfo, TSelect>> selectExpression,
|
Expression<Func<ServerInfo, TSelect>> selectExpression,
|
||||||
|
bool includeExpired = false,
|
||||||
Expression<Func<ServerInfo, bool>> whereExpression = null,
|
Expression<Func<ServerInfo, bool>> whereExpression = null,
|
||||||
string partitionKey = null);
|
string partitionKey = null);
|
||||||
|
|
||||||
|
@ -36,7 +36,10 @@
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<IEnumerable<ServerInfo>> GetServerInfos(Expression<Func<ServerInfo, bool>> whereExpression = null, string partitionKey = null)
|
public Task<IEnumerable<ServerInfo>> GetServerInfos(
|
||||||
|
Expression<Func<ServerInfo, bool>> whereExpression = null,
|
||||||
|
bool includeExpired = false,
|
||||||
|
string partitionKey = null)
|
||||||
{
|
{
|
||||||
IQueryable<ServerInfo> serverInfoQuery = this.servers.Values.AsQueryable();
|
IQueryable<ServerInfo> serverInfoQuery = this.servers.Values.AsQueryable();
|
||||||
|
|
||||||
@ -48,7 +51,11 @@
|
|||||||
return Task.FromResult(serverInfoQuery.AsEnumerable());
|
return Task.FromResult(serverInfoQuery.AsEnumerable());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<IEnumerable<TSelect>> GetServerInfos<TSelect>(Expression<Func<ServerInfo, TSelect>> selectExpression, Expression<Func<ServerInfo, bool>> whereExpression = null, string partitionKey = null)
|
public Task<IEnumerable<TSelect>> GetServerInfos<TSelect>(
|
||||||
|
Expression<Func<ServerInfo, TSelect>> selectExpression,
|
||||||
|
bool includeExpired = false,
|
||||||
|
Expression <Func<ServerInfo, bool>> whereExpression = null,
|
||||||
|
string partitionKey = null)
|
||||||
{
|
{
|
||||||
IQueryable<ServerInfo> serverInfoQuery = this.servers.Values.AsQueryable();
|
IQueryable<ServerInfo> serverInfoQuery = this.servers.Values.AsQueryable();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user