add all requirements for implementing XAiMcpClient ...
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace xAiService.Services
|
||||
{
|
||||
public class XAiMcpSessionCleanupService : BackgroundService
|
||||
{
|
||||
//
|
||||
private readonly XAiMcpSessionStore store;
|
||||
private readonly ILogger<XAiMcpSessionCleanupService> logger;
|
||||
|
||||
public XAiMcpSessionCleanupService(
|
||||
XAiMcpSessionStore store,
|
||||
ILogger<XAiMcpSessionCleanupService> logger
|
||||
)
|
||||
{
|
||||
//
|
||||
this.store = store;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
//
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
//
|
||||
await Task.Delay(TimeSpan.FromMinutes(5), stoppingToken);
|
||||
var removed = store.CleanupExpired();
|
||||
if (removed > 0)
|
||||
{
|
||||
//
|
||||
logger
|
||||
.LogInformation("MCP Session Cleanup: {Count} expired sessions removed", removed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user