From 926769d354cd30a718d5d949f6b3da6a761c00a3 Mon Sep 17 00:00:00 2001 From: yangxiaodong Date: Fri, 28 Jul 2017 17:37:25 +0800 Subject: [PATCH] cleanup code. --- src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs | 2 +- src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs | 1 - src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs | 2 +- src/DotNetCore.CAP.MySql/IAdditionalProcessor.Default.cs | 1 - src/DotNetCore.CAP.MySql/MySqlStorage.cs | 1 - src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs | 4 ++-- src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs | 1 + src/DotNetCore.CAP.SqlServer/CapPublisher.cs | 2 +- src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs | 2 +- src/DotNetCore.CAP/Abstractions/ConsumerContext.cs | 1 - .../Abstractions/ModelBinding/ModelBindingResult.cs | 2 +- src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs | 3 +-- src/DotNetCore.CAP/IStorageConnection.cs | 1 + src/DotNetCore.CAP/Infrastructure/WebHookProvider.cs | 4 +--- src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs | 2 -- src/DotNetCore.CAP/Internal/HashCodeCombiner.cs | 2 +- src/DotNetCore.CAP/Internal/IConsumerInvoker.Default.cs | 2 +- src/DotNetCore.CAP/Internal/IModelBinder.ComplexType.cs | 1 - src/DotNetCore.CAP/Internal/IModelBinder.SimpleType.cs | 2 +- src/DotNetCore.CAP/Internal/IModelBinderFactory.cs | 2 +- src/DotNetCore.CAP/Models/CapPublishedMessage.cs | 1 - src/DotNetCore.CAP/Models/CapReceivedMessage.cs | 1 - src/DotNetCore.CAP/Processor/IProcessingServer.Cap.cs | 2 +- src/DotNetCore.CAP/Processor/IProcessor.FailedJob.cs | 5 +---- src/DotNetCore.CAP/QueueExecutorFactory.cs | 4 ++-- 25 files changed, 19 insertions(+), 32 deletions(-) diff --git a/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs b/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs index 2dbf888..a5fb020 100644 --- a/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs +++ b/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs @@ -21,7 +21,7 @@ namespace DotNetCore.CAP var kafkaOptions = new KafkaOptions(); _configure(kafkaOptions); services.AddSingleton(kafkaOptions); - + services.AddSingleton(); services.AddTransient(); } diff --git a/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs b/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs index df49e8a..ad835e9 100644 --- a/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs +++ b/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs @@ -2,7 +2,6 @@ using System.Text; using System.Threading.Tasks; using Confluent.Kafka; -using Confluent.Kafka.Serialization; using DotNetCore.CAP.Processor.States; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; diff --git a/src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs b/src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs index 47d0bff..133b2db 100644 --- a/src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs +++ b/src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs @@ -1,6 +1,6 @@ using System; -using DotNetCore.CAP.Processor; using DotNetCore.CAP.MySql; +using DotNetCore.CAP.Processor; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; diff --git a/src/DotNetCore.CAP.MySql/IAdditionalProcessor.Default.cs b/src/DotNetCore.CAP.MySql/IAdditionalProcessor.Default.cs index ac394dd..6529678 100644 --- a/src/DotNetCore.CAP.MySql/IAdditionalProcessor.Default.cs +++ b/src/DotNetCore.CAP.MySql/IAdditionalProcessor.Default.cs @@ -1,5 +1,4 @@ using System; -using System.Data.SqlClient; using System.Threading.Tasks; using Dapper; using DotNetCore.CAP.Processor; diff --git a/src/DotNetCore.CAP.MySql/MySqlStorage.cs b/src/DotNetCore.CAP.MySql/MySqlStorage.cs index 9813d0f..137a69f 100644 --- a/src/DotNetCore.CAP.MySql/MySqlStorage.cs +++ b/src/DotNetCore.CAP.MySql/MySqlStorage.cs @@ -1,4 +1,3 @@ -using System.Data.SqlClient; using System.Threading; using System.Threading.Tasks; using Dapper; diff --git a/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs b/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs index bbde1cb..946f697 100644 --- a/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs +++ b/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs @@ -46,7 +46,7 @@ namespace DotNetCore.CAP.MySql //SELECT MessageId,MessageType FROM `{_prefix}.queue` LIMIT 1 FOR UPDATE; //DELETE FROM `{_prefix}.queue` LIMIT 1; //COMMIT; - + var sql = $@" SELECT `MessageId`,`MessageType` FROM `{_prefix}.queue` LIMIT 1 FOR UPDATE; DELETE FROM `{_prefix}.queue` LIMIT 1;"; @@ -123,7 +123,7 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);"; private async Task FetchNextMessageCoreAsync(string sql, object args = null) { - //here don't use `using` to dispose + //here don't use `using` to dispose var connection = new MySqlConnection(_options.ConnectionString); await connection.OpenAsync(); var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted); diff --git a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs index 483b2f4..444919c 100644 --- a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs +++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs @@ -19,6 +19,7 @@ namespace DotNetCore.CAP.RabbitMQ private ulong _deliveryTag; public event EventHandler OnMessageReceieved; + public event EventHandler OnError; public RabbitMQConsumerClient(string queueName, RabbitMQOptions options) diff --git a/src/DotNetCore.CAP.SqlServer/CapPublisher.cs b/src/DotNetCore.CAP.SqlServer/CapPublisher.cs index d63b3f2..674b7f7 100644 --- a/src/DotNetCore.CAP.SqlServer/CapPublisher.cs +++ b/src/DotNetCore.CAP.SqlServer/CapPublisher.cs @@ -55,7 +55,7 @@ namespace DotNetCore.CAP.SqlServer return PublishCoreAsync(name, content); } - + public void Publish(string name, T contentObj, IDbConnection dbConnection, IDbTransaction dbTransaction = null) { CheckIsAdoNet(name); diff --git a/src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs b/src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs index 6cd89f5..b8fba46 100644 --- a/src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs +++ b/src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs @@ -114,7 +114,7 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);"; private async Task FetchNextMessageCoreAsync(string sql, object args = null) { - //here don't use `using` to dispose + //here don't use `using` to dispose var connection = new SqlConnection(_options.ConnectionString); await connection.OpenAsync(); var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted); diff --git a/src/DotNetCore.CAP/Abstractions/ConsumerContext.cs b/src/DotNetCore.CAP/Abstractions/ConsumerContext.cs index 7c8ece6..bb0cbb4 100644 --- a/src/DotNetCore.CAP/Abstractions/ConsumerContext.cs +++ b/src/DotNetCore.CAP/Abstractions/ConsumerContext.cs @@ -1,5 +1,4 @@ using System; -using DotNetCore.CAP.Infrastructure; namespace DotNetCore.CAP.Abstractions { diff --git a/src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingResult.cs b/src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingResult.cs index 105872f..b2896c1 100644 --- a/src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingResult.cs +++ b/src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingResult.cs @@ -102,4 +102,4 @@ namespace DotNetCore.CAP.Abstractions.ModelBinding return !x.Equals(y); } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs b/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs index 0d1712b..085205e 100644 --- a/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs +++ b/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Reflection; using DotNetCore.CAP; using DotNetCore.CAP.Abstractions; -using DotNetCore.CAP.Abstractions.ModelBinding; using DotNetCore.CAP.Infrastructure; using DotNetCore.CAP.Internal; using DotNetCore.CAP.Processor; @@ -60,7 +59,7 @@ namespace Microsoft.Extensions.DependencyInjection foreach (var serviceExtension in options.Extensions) { serviceExtension.AddServices(services); - } + } services.AddSingleton(options); return new CapBuilder(services); diff --git a/src/DotNetCore.CAP/IStorageConnection.cs b/src/DotNetCore.CAP/IStorageConnection.cs index e481a56..33b022b 100644 --- a/src/DotNetCore.CAP/IStorageConnection.cs +++ b/src/DotNetCore.CAP/IStorageConnection.cs @@ -56,6 +56,7 @@ namespace DotNetCore.CAP /// Returns executed failed message. /// Task> GetFailedReceviedMessages(); + //----------------------------------------- /// diff --git a/src/DotNetCore.CAP/Infrastructure/WebHookProvider.cs b/src/DotNetCore.CAP/Infrastructure/WebHookProvider.cs index d2492dd..18a2bd1 100644 --- a/src/DotNetCore.CAP/Infrastructure/WebHookProvider.cs +++ b/src/DotNetCore.CAP/Infrastructure/WebHookProvider.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace DotNetCore.CAP.Infrastructure { @@ -11,4 +9,4 @@ namespace DotNetCore.CAP.Infrastructure throw new NotImplementedException(); } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs b/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs index 6c87935..0921e1b 100644 --- a/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs +++ b/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs @@ -1,7 +1,5 @@ using System; using DotNetCore.CAP.Abstractions; -using DotNetCore.CAP.Abstractions.ModelBinding; -using DotNetCore.CAP.Infrastructure; using Microsoft.Extensions.Logging; namespace DotNetCore.CAP.Internal diff --git a/src/DotNetCore.CAP/Internal/HashCodeCombiner.cs b/src/DotNetCore.CAP/Internal/HashCodeCombiner.cs index 2b48174..205f541 100644 --- a/src/DotNetCore.CAP/Internal/HashCodeCombiner.cs +++ b/src/DotNetCore.CAP/Internal/HashCodeCombiner.cs @@ -78,4 +78,4 @@ namespace DotNetCore.CAP.Internal return new HashCodeCombiner(0x1505L); } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Internal/IConsumerInvoker.Default.cs b/src/DotNetCore.CAP/Internal/IConsumerInvoker.Default.cs index 26917fc..28ca3a4 100644 --- a/src/DotNetCore.CAP/Internal/IConsumerInvoker.Default.cs +++ b/src/DotNetCore.CAP/Internal/IConsumerInvoker.Default.cs @@ -57,7 +57,7 @@ namespace DotNetCore.CAP.Internal catch (FormatException ex) { _logger.ModelBinderFormattingException(_executor.MethodInfo?.Name, firstParameter.Name, value, ex); - } + } } else { diff --git a/src/DotNetCore.CAP/Internal/IModelBinder.ComplexType.cs b/src/DotNetCore.CAP/Internal/IModelBinder.ComplexType.cs index ade36ba..c25f7c6 100644 --- a/src/DotNetCore.CAP/Internal/IModelBinder.ComplexType.cs +++ b/src/DotNetCore.CAP/Internal/IModelBinder.ComplexType.cs @@ -26,7 +26,6 @@ namespace DotNetCore.CAP.Internal catch (Exception) { return Task.FromResult(ModelBindingResult.Failed()); - } } } diff --git a/src/DotNetCore.CAP/Internal/IModelBinder.SimpleType.cs b/src/DotNetCore.CAP/Internal/IModelBinder.SimpleType.cs index ddaf9a9..d00f8b8 100644 --- a/src/DotNetCore.CAP/Internal/IModelBinder.SimpleType.cs +++ b/src/DotNetCore.CAP/Internal/IModelBinder.SimpleType.cs @@ -83,4 +83,4 @@ namespace DotNetCore.CAP.Internal return !type.GetTypeInfo().IsValueType || isNullableValueType; } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Internal/IModelBinderFactory.cs b/src/DotNetCore.CAP/Internal/IModelBinderFactory.cs index 6918401..0922ea7 100644 --- a/src/DotNetCore.CAP/Internal/IModelBinderFactory.cs +++ b/src/DotNetCore.CAP/Internal/IModelBinderFactory.cs @@ -7,4 +7,4 @@ namespace DotNetCore.CAP.Internal { IModelBinder CreateBinder(ParameterInfo parameter); } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Models/CapPublishedMessage.cs b/src/DotNetCore.CAP/Models/CapPublishedMessage.cs index 24dfbcc..c23f24d 100644 --- a/src/DotNetCore.CAP/Models/CapPublishedMessage.cs +++ b/src/DotNetCore.CAP/Models/CapPublishedMessage.cs @@ -1,5 +1,4 @@ using System; -using DotNetCore.CAP.Infrastructure; namespace DotNetCore.CAP.Models { diff --git a/src/DotNetCore.CAP/Models/CapReceivedMessage.cs b/src/DotNetCore.CAP/Models/CapReceivedMessage.cs index bfb0103..069e4d0 100644 --- a/src/DotNetCore.CAP/Models/CapReceivedMessage.cs +++ b/src/DotNetCore.CAP/Models/CapReceivedMessage.cs @@ -1,5 +1,4 @@ using System; -using DotNetCore.CAP.Infrastructure; namespace DotNetCore.CAP.Models { diff --git a/src/DotNetCore.CAP/Processor/IProcessingServer.Cap.cs b/src/DotNetCore.CAP/Processor/IProcessingServer.Cap.cs index d8328bc..a79cc84 100644 --- a/src/DotNetCore.CAP/Processor/IProcessingServer.Cap.cs +++ b/src/DotNetCore.CAP/Processor/IProcessingServer.Cap.cs @@ -61,7 +61,7 @@ namespace DotNetCore.CAP.Processor _logger.LogTrace("Pulsing the Queuer."); - PublishQueuer.PulseEvent.Set(); + PublishQueuer.PulseEvent.Set(); } public void Dispose() diff --git a/src/DotNetCore.CAP/Processor/IProcessor.FailedJob.cs b/src/DotNetCore.CAP/Processor/IProcessor.FailedJob.cs index 9d5f12d..7f897d0 100644 --- a/src/DotNetCore.CAP/Processor/IProcessor.FailedJob.cs +++ b/src/DotNetCore.CAP/Processor/IProcessor.FailedJob.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Text; using System.Threading.Tasks; using DotNetCore.CAP.Processor.States; using Microsoft.Extensions.DependencyInjection; @@ -83,4 +80,4 @@ namespace DotNetCore.CAP.Processor } } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/QueueExecutorFactory.cs b/src/DotNetCore.CAP/QueueExecutorFactory.cs index d76f09f..ed28fe8 100644 --- a/src/DotNetCore.CAP/QueueExecutorFactory.cs +++ b/src/DotNetCore.CAP/QueueExecutorFactory.cs @@ -18,8 +18,8 @@ namespace DotNetCore.CAP { var queueExectors = _serviceProvider.GetServices(); - return messageType == MessageType.Publish - ? queueExectors.FirstOrDefault(x => x is BasePublishQueueExecutor) + return messageType == MessageType.Publish + ? queueExectors.FirstOrDefault(x => x is BasePublishQueueExecutor) : queueExectors.FirstOrDefault(x => !(x is BasePublishQueueExecutor)); } }