Compare commits
No commits in common. "c999b0a0a982f5abe18e8ecfa285e0c358be7b72" and "db8b0e0b231f4034b9e52e3cf448b45fd53f86f8" have entirely different histories.
c999b0a0a9
...
db8b0e0b23
@ -8,11 +8,10 @@ using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace JiShe.CollectBus.Kafka.AdminClient;
|
||||
|
||||
public class AdminClientService : IAdminClientService, ISingletonDependency
|
||||
public class AdminClientService : IAdminClientService, IDisposable, ISingletonDependency
|
||||
{
|
||||
private readonly ILogger<AdminClientService> _logger;
|
||||
private readonly KafkaOptionConfig _kafkaOptionConfig;
|
||||
private readonly Lazy<IAdminClient> _lazyAdminClient;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AdminClientService" /> class.
|
||||
/// </summary>
|
||||
@ -22,8 +21,7 @@ public class AdminClientService : IAdminClientService, ISingletonDependency
|
||||
{
|
||||
_logger = logger;
|
||||
_kafkaOptionConfig = kafkaOptionConfig.Value;
|
||||
//Instance = GetInstance();
|
||||
_lazyAdminClient = new Lazy<IAdminClient>(() => GetInstance());
|
||||
Instance = GetInstance();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -32,7 +30,7 @@ public class AdminClientService : IAdminClientService, ISingletonDependency
|
||||
/// <value>
|
||||
/// The instance.
|
||||
/// </value>
|
||||
public IAdminClient Instance => _lazyAdminClient.Value;
|
||||
public IAdminClient Instance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建Kafka主题
|
||||
@ -139,6 +137,11 @@ public class AdminClientService : IAdminClientService, ISingletonDependency
|
||||
return metadata.Topics[0].Partitions.Count;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Instance?.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance.
|
||||
/// </summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user