Compare commits
2 Commits
db8b0e0b23
...
c999b0a0a9
| Author | SHA1 | Date | |
|---|---|---|---|
| c999b0a0a9 | |||
| 679086b174 |
@ -8,10 +8,11 @@ using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace JiShe.CollectBus.Kafka.AdminClient;
|
||||
|
||||
public class AdminClientService : IAdminClientService, IDisposable, ISingletonDependency
|
||||
public class AdminClientService : IAdminClientService, 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>
|
||||
@ -21,7 +22,8 @@ public class AdminClientService : IAdminClientService, IDisposable, ISingletonDe
|
||||
{
|
||||
_logger = logger;
|
||||
_kafkaOptionConfig = kafkaOptionConfig.Value;
|
||||
Instance = GetInstance();
|
||||
//Instance = GetInstance();
|
||||
_lazyAdminClient = new Lazy<IAdminClient>(() => GetInstance());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -30,7 +32,7 @@ public class AdminClientService : IAdminClientService, IDisposable, ISingletonDe
|
||||
/// <value>
|
||||
/// The instance.
|
||||
/// </value>
|
||||
public IAdminClient Instance { get; set; }
|
||||
public IAdminClient Instance => _lazyAdminClient.Value;
|
||||
|
||||
/// <summary>
|
||||
/// 创建Kafka主题
|
||||
@ -137,11 +139,6 @@ public class AdminClientService : IAdminClientService, IDisposable, ISingletonDe
|
||||
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