diff --git a/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs b/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs index a5fb020..8d9bf98 100644 --- a/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs +++ b/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection; // ReSharper disable once CheckNamespace namespace DotNetCore.CAP { - public class KafkaCapOptionsExtension : ICapOptionsExtension + internal sealed class KafkaCapOptionsExtension : ICapOptionsExtension { private readonly Action _configure; @@ -16,10 +16,8 @@ namespace DotNetCore.CAP public void AddServices(IServiceCollection services) { - services.Configure(_configure); - var kafkaOptions = new KafkaOptions(); - _configure(kafkaOptions); + _configure?.Invoke(kafkaOptions); services.AddSingleton(kafkaOptions); services.AddSingleton(); diff --git a/src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs b/src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs index fa6dd2b..5bf11b1 100644 --- a/src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs +++ b/src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs @@ -6,6 +6,10 @@ namespace Microsoft.Extensions.DependencyInjection { public static class CapOptionsExtensions { + /// + /// Configuration to use kafka in CAP. + /// + /// Kafka bootstrap server urls. public static CapOptions UseKafka(this CapOptions options, string bootstrapServers) { return options.UseKafka(opt => @@ -14,6 +18,11 @@ namespace Microsoft.Extensions.DependencyInjection }); } + /// + /// Configuration to use kafka in CAP. + /// + /// Provides programmatic configuration for the kafka . + /// public static CapOptions UseKafka(this CapOptions options, Action configure) { if (configure == null) throw new ArgumentNullException(nameof(configure)); diff --git a/src/DotNetCore.CAP.Kafka/CAP.SubscribeAttribute.cs b/src/DotNetCore.CAP.Kafka/CAP.SubscribeAttribute.cs index 06ec6e6..161b073 100644 --- a/src/DotNetCore.CAP.Kafka/CAP.SubscribeAttribute.cs +++ b/src/DotNetCore.CAP.Kafka/CAP.SubscribeAttribute.cs @@ -3,6 +3,9 @@ // ReSharper disable once CheckNamespace namespace DotNetCore.CAP { + /// + /// An attribute for subscribe Kafka messages. + /// public class CapSubscribeAttribute : TopicAttribute { public CapSubscribeAttribute(string name) diff --git a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs index 834eb8a..3a692b9 100644 --- a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs +++ b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs @@ -6,7 +6,7 @@ using Confluent.Kafka.Serialization; namespace DotNetCore.CAP.Kafka { - public class KafkaConsumerClient : IConsumerClient + internal sealed class KafkaConsumerClient : IConsumerClient { private readonly string _groupId; private readonly KafkaOptions _kafkaOptions; diff --git a/src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs b/src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs index 593e6ce..ea2ee67 100644 --- a/src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs +++ b/src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs @@ -3,13 +3,13 @@ using Microsoft.Extensions.Options; namespace DotNetCore.CAP.Kafka { - public class KafkaConsumerClientFactory : IConsumerClientFactory + internal sealed class KafkaConsumerClientFactory : IConsumerClientFactory { private readonly KafkaOptions _kafkaOptions; - public KafkaConsumerClientFactory(IOptions kafkaOptions) + public KafkaConsumerClientFactory(KafkaOptions kafkaOptions) { - _kafkaOptions = kafkaOptions?.Value ?? throw new ArgumentNullException(nameof(kafkaOptions)); + _kafkaOptions = kafkaOptions; } public IConsumerClient Create(string groupId) diff --git a/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs b/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs index f7d6aed..a3f4c80 100644 --- a/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs +++ b/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs @@ -4,22 +4,21 @@ using System.Threading.Tasks; using Confluent.Kafka; using DotNetCore.CAP.Processor.States; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; namespace DotNetCore.CAP.Kafka { - public class PublishQueueExecutor : BasePublishQueueExecutor + internal class PublishQueueExecutor : BasePublishQueueExecutor { private readonly ILogger _logger; private readonly KafkaOptions _kafkaOptions; public PublishQueueExecutor(IStateChanger stateChanger, - IOptions options, + KafkaOptions options, ILogger logger) : base(stateChanger, logger) { _logger = logger; - _kafkaOptions = options.Value; + _kafkaOptions = options; } public override Task PublishAsync(string keyName, string content) diff --git a/src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs b/src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs index 133b2db..5682e38 100644 --- a/src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs +++ b/src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection; // ReSharper disable once CheckNamespace namespace DotNetCore.CAP { - public class MySqlCapOptionsExtension : ICapOptionsExtension + internal class MySqlCapOptionsExtension : ICapOptionsExtension { private readonly Action _configure; diff --git a/src/DotNetCore.CAP.MySql/FetchedMessage.cs b/src/DotNetCore.CAP.MySql/FetchedMessage.cs index c14c549..a0f3b8e 100644 --- a/src/DotNetCore.CAP.MySql/FetchedMessage.cs +++ b/src/DotNetCore.CAP.MySql/FetchedMessage.cs @@ -2,7 +2,7 @@ namespace DotNetCore.CAP.MySql { - public class FetchedMessage + internal class FetchedMessage { public int MessageId { get; set; } diff --git a/src/DotNetCore.CAP.MySql/IAdditionalProcessor.Default.cs b/src/DotNetCore.CAP.MySql/IAdditionalProcessor.Default.cs index 6529678..b8e5922 100644 --- a/src/DotNetCore.CAP.MySql/IAdditionalProcessor.Default.cs +++ b/src/DotNetCore.CAP.MySql/IAdditionalProcessor.Default.cs @@ -7,7 +7,7 @@ using MySql.Data.MySqlClient; namespace DotNetCore.CAP.MySql { - public class DefaultAdditionalProcessor : IAdditionalProcessor + internal class DefaultAdditionalProcessor : IAdditionalProcessor { private readonly IServiceProvider _provider; private readonly ILogger _logger; diff --git a/src/DotNetCore.CAP.RabbitMQ/CAP.Options.Extensions.cs b/src/DotNetCore.CAP.RabbitMQ/CAP.Options.Extensions.cs index 4d59112..ff1138d 100644 --- a/src/DotNetCore.CAP.RabbitMQ/CAP.Options.Extensions.cs +++ b/src/DotNetCore.CAP.RabbitMQ/CAP.Options.Extensions.cs @@ -4,7 +4,7 @@ using DotNetCore.CAP; // ReSharper disable once CheckNamespace namespace Microsoft.Extensions.DependencyInjection { - public static class CapOptionsExtensions + internal static class CapOptionsExtensions { public static CapOptions UseRabbitMQ(this CapOptions options, string hostName) { diff --git a/src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs b/src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs index 14eedbb..4202570 100644 --- a/src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs +++ b/src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection; // ReSharper disable once CheckNamespace namespace DotNetCore.CAP { - public class RabbitMQCapOptionsExtension : ICapOptionsExtension + internal sealed class RabbitMQCapOptionsExtension : ICapOptionsExtension { private readonly Action _configure; @@ -16,12 +16,9 @@ namespace DotNetCore.CAP public void AddServices(IServiceCollection services) { - services.Configure(_configure); - - var rabbitMQOptions = new RabbitMQOptions(); - _configure(rabbitMQOptions); - - services.AddSingleton(rabbitMQOptions); + var options = new RabbitMQOptions(); + _configure?.Invoke(options); + services.AddSingleton(options); services.AddSingleton(); services.AddTransient(); diff --git a/src/DotNetCore.CAP.RabbitMQ/CAP.SubscribeAttribute.cs b/src/DotNetCore.CAP.RabbitMQ/CAP.SubscribeAttribute.cs index 92fb295..811a281 100644 --- a/src/DotNetCore.CAP.RabbitMQ/CAP.SubscribeAttribute.cs +++ b/src/DotNetCore.CAP.RabbitMQ/CAP.SubscribeAttribute.cs @@ -3,6 +3,9 @@ // ReSharper disable once CheckNamespace namespace DotNetCore.CAP { + /// + /// An attribute for subscribe RabbitMQ messages. + /// public class CapSubscribeAttribute : TopicAttribute { public CapSubscribeAttribute(string name) : base(name) diff --git a/src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs b/src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs index 3e439e2..17b0ee2 100644 --- a/src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs +++ b/src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs @@ -8,18 +8,18 @@ using RabbitMQ.Client; namespace DotNetCore.CAP.RabbitMQ { - public class PublishQueueExecutor : BasePublishQueueExecutor + internal sealed class PublishQueueExecutor : BasePublishQueueExecutor { private readonly ILogger _logger; private readonly RabbitMQOptions _rabbitMQOptions; public PublishQueueExecutor(IStateChanger stateChanger, - IOptions options, + RabbitMQOptions options, ILogger logger) : base(stateChanger, logger) { _logger = logger; - _rabbitMQOptions = options.Value; + _rabbitMQOptions = options; } public override Task PublishAsync(string keyName, string content) diff --git a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs index 444919c..795b942 100644 --- a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs +++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs @@ -7,7 +7,7 @@ using RabbitMQ.Client.Events; namespace DotNetCore.CAP.RabbitMQ { - public class RabbitMQConsumerClient : IConsumerClient + internal sealed class RabbitMQConsumerClient : IConsumerClient { private readonly string _exchageName; private readonly string _queueName; diff --git a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs index 2d64f0c..fcd267d 100644 --- a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs +++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs @@ -2,13 +2,13 @@ namespace DotNetCore.CAP.RabbitMQ { - public class RabbitMQConsumerClientFactory : IConsumerClientFactory + internal sealed class RabbitMQConsumerClientFactory : IConsumerClientFactory { private readonly RabbitMQOptions _rabbitMQOptions; - public RabbitMQConsumerClientFactory(IOptions rabbitMQOptions) + public RabbitMQConsumerClientFactory(RabbitMQOptions rabbitMQOptions) { - _rabbitMQOptions = rabbitMQOptions.Value; + _rabbitMQOptions = rabbitMQOptions; } public IConsumerClient Create(string groupId) diff --git a/src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs b/src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs index 72ff738..2d1878e 100644 --- a/src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs +++ b/src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection; // ReSharper disable once CheckNamespace namespace DotNetCore.CAP { - public class SqlServerCapOptionsExtension : ICapOptionsExtension + internal class SqlServerCapOptionsExtension : ICapOptionsExtension { private readonly Action _configure; diff --git a/src/DotNetCore.CAP.SqlServer/FetchedMessage.cs b/src/DotNetCore.CAP.SqlServer/FetchedMessage.cs index 521fdeb..990b61e 100644 --- a/src/DotNetCore.CAP.SqlServer/FetchedMessage.cs +++ b/src/DotNetCore.CAP.SqlServer/FetchedMessage.cs @@ -2,7 +2,7 @@ namespace DotNetCore.CAP.SqlServer { - public class FetchedMessage + internal class FetchedMessage { public int MessageId { get; set; }