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;
|
namespace JiShe.CollectBus.Kafka.AdminClient;
|
||||||
|
|
||||||
public class AdminClientService : IAdminClientService, ISingletonDependency
|
public class AdminClientService : IAdminClientService, IDisposable, 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>
|
||||||
@ -22,8 +21,7 @@ public class AdminClientService : IAdminClientService, ISingletonDependency
|
|||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_kafkaOptionConfig = kafkaOptionConfig.Value;
|
_kafkaOptionConfig = kafkaOptionConfig.Value;
|
||||||
//Instance = GetInstance();
|
Instance = GetInstance();
|
||||||
_lazyAdminClient = new Lazy<IAdminClient>(() => GetInstance());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -32,7 +30,7 @@ public class AdminClientService : IAdminClientService, ISingletonDependency
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The instance.
|
/// The instance.
|
||||||
/// </value>
|
/// </value>
|
||||||
public IAdminClient Instance => _lazyAdminClient.Value;
|
public IAdminClient Instance { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建Kafka主题
|
/// 创建Kafka主题
|
||||||
@ -139,6 +137,11 @@ public class AdminClientService : IAdminClientService, ISingletonDependency
|
|||||||
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