forked from anjoy8/Blog.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKafkaSetup.cs
More file actions
26 lines (24 loc) · 832 Bytes
/
KafkaSetup.cs
File metadata and controls
26 lines (24 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using Blog.Core.Common;
using Blog.Core.EventBus;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
namespace Blog.Core.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>();
}
}
}
}