| | 1 | | using System.Collections.Generic; |
| | 2 | | using System.Linq; |
| | 3 | | using SeungYongShim.Kafka; |
| | 4 | | using SeungYongShim.ProtobufHelper; |
| | 5 | |
|
| | 6 | | namespace Microsoft.Extensions.DependencyInjection |
| | 7 | | { |
| | 8 | | public static class AddKafkaExtension |
| | 9 | | { |
| | 10 | | internal static IServiceCollection AddKafka(this IServiceCollection services, |
| | 11 | | KafkaConfig kafkaConfig, |
| | 12 | | IEnumerable<string> searchPatterns) |
| 2 | 13 | | { |
| 2 | 14 | | services.AddTransient<KafkaConsumer>(); |
| 2 | 15 | | services.AddTransient<KafkaProducer>(); |
| 4 | 16 | | services.AddSingleton(sp => new ProtoKnownTypes(searchPatterns.ToArray())); |
| 4 | 17 | | services.AddSingleton(sp => kafkaConfig); |
| | 18 | |
|
| 2 | 19 | | return services; |
| 2 | 20 | | } |
| | 21 | | } |
| | 22 | | } |