You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
844 B
C#

using EntrustSettle.Common;
using EntrustSettle.EventBus;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
namespace EntrustSettle.Extensions
{
/// <summary>
/// 注入Kafka相关配置
/// </summary>
public static class KafkaSetup
{
public static void AddKafkaSetup(this IServiceCollection services,IConfiguration configuration)
{
if (services == null) throw new ArgumentNullException(nameof(services));
if (AppSettings.app(new string[] { "Kafka", "Enabled" }).ObjToBool())
{
services.Configure<KafkaOptions>(configuration.GetSection("kafka"));
services.AddSingleton<IKafkaConnectionPool,KafkaConnectionPool>();
}
}
}
}