diff --git a/src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs b/src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs index ff25fa6..b6a6e00 100644 --- a/src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs +++ b/src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs @@ -2,10 +2,12 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System; +using DotNetCore.CAP.Internal; using DotNetCore.CAP.Persistence; using DotNetCore.CAP.SqlServer; using DotNetCore.CAP.SqlServer.Diagnostics; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; // ReSharper disable once CheckNamespace @@ -28,6 +30,7 @@ namespace DotNetCore.CAP services.AddSingleton(); services.AddSingleton(); services.AddTransient(); + services.TryAddEnumerable(ServiceDescriptor.Singleton()); services.Configure(_configure); services.AddSingleton, ConfigureSqlServerOptions>(); diff --git a/src/DotNetCore.CAP.SqlServer/Diagnostics/IProcessingServer.DiagnosticRegister.cs b/src/DotNetCore.CAP.SqlServer/Diagnostics/IProcessingServer.DiagnosticRegister.cs new file mode 100644 index 0000000..53b227c --- /dev/null +++ b/src/DotNetCore.CAP.SqlServer/Diagnostics/IProcessingServer.DiagnosticRegister.cs @@ -0,0 +1,33 @@ +// Copyright (c) .NET Core Community. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System.Diagnostics; +using DotNetCore.CAP.Internal; + +namespace DotNetCore.CAP.SqlServer.Diagnostics +{ + public class DiagnosticRegister : IProcessingServer + { + private readonly DiagnosticProcessorObserver _diagnosticProcessorObserver; + + public DiagnosticRegister(DiagnosticProcessorObserver diagnosticProcessorObserver) + { + _diagnosticProcessorObserver = diagnosticProcessorObserver; + } + + public void Dispose() + { + + } + + public void Pulse() + { + + } + + public void Start() + { + DiagnosticListener.AllListeners.Subscribe(_diagnosticProcessorObserver); + } + } +} diff --git a/src/DotNetCore.CAP.SqlServer/IStorageInitializer.SqlServer.cs b/src/DotNetCore.CAP.SqlServer/IStorageInitializer.SqlServer.cs index 9d4c911..8c0e7c7 100644 --- a/src/DotNetCore.CAP.SqlServer/IStorageInitializer.SqlServer.cs +++ b/src/DotNetCore.CAP.SqlServer/IStorageInitializer.SqlServer.cs @@ -1,12 +1,10 @@ // Copyright (c) .NET Core Community. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -using System.Diagnostics; using System.Threading; using System.Threading.Tasks; using Dapper; using DotNetCore.CAP.Persistence; -using DotNetCore.CAP.SqlServer.Diagnostics; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -15,17 +13,14 @@ namespace DotNetCore.CAP.SqlServer { public class SqlServerStorageInitializer : IStorageInitializer { - private readonly DiagnosticProcessorObserver _diagnosticProcessorObserver; private readonly ILogger _logger; private readonly IOptions _options; public SqlServerStorageInitializer( ILogger logger, - IOptions options, - DiagnosticProcessorObserver diagnosticProcessorObserver) + IOptions options) { _options = options; - _diagnosticProcessorObserver = diagnosticProcessorObserver; _logger = logger; } @@ -50,11 +45,8 @@ namespace DotNetCore.CAP.SqlServer } _logger.LogDebug("Ensuring all create database tables script are applied."); - - DiagnosticListener.AllListeners.Subscribe(_diagnosticProcessorObserver); } - protected virtual string CreateDbTablesScript(string schema) { var batchSql =