in src/DotPulsar/Internal/ConnectionPool.cs [202:229]
private async Task CloseInactiveConnections(TimeSpan interval, CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
try
{
await Task.Delay(interval, cancellationToken).ConfigureAwait(false);
using (await _lock.Lock(cancellationToken).ConfigureAwait(false))
{
var serviceUrls = _connections.Keys;
foreach (var serviceUrl in serviceUrls)
{
var connection = _connections[serviceUrl];
if (connection is null)
continue;
if (!await connection.HasChannels(cancellationToken).ConfigureAwait(false))
await DisposeConnection(serviceUrl).ConfigureAwait(false);
}
}
}
catch
{
// ignored
}
}
}