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