diff --git a/Masa.Framework.sln b/Masa.Framework.sln index a2693817b..5bf6e4ae1 100644 --- a/Masa.Framework.sln +++ b/Masa.Framework.sln @@ -125,8 +125,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ldap", "Ldap", "{0BC7A7F2-F8E0-4A6A-90E2-A0ACD997EBB1}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Models", "Models", "{9CABAF1C-E5E1-4CB8-AAD4-D47387EED6AA}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Security", "Security", "{2D07F9AD-9951-475D-B7C7-980B23FDE9BB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Authentication", "Authentication", "{534346EF-1D11-48DB-9909-700CEC99FF08}" @@ -135,8 +133,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Utils.Caching.Memory", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Utils.Exceptions", "src\Utils\Masa.Utils.Exceptions\Masa.Utils.Exceptions.csproj", "{7B0EDB07-D3AE-4077-9A23-35CA6556E791}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Utils.Configuration.Dcc", "src\Utils\Configuration\Masa.Utils.Configuration.Dcc\Masa.Utils.Configuration.Dcc.csproj", "{E376F15A-3C13-4DBF-B972-E03D2350D7C4}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Utils.Configuration.Json", "src\Utils\Configuration\Masa.Utils.Configuration.Json\Masa.Utils.Configuration.Json.csproj", "{8AB652AF-3957-42F9-8F3E-FAFE56A44BE1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Utils.Data.DataAnnotations", "src\Utils\Data\Masa.Utils.Data.DataAnnotations\Masa.Utils.Data.DataAnnotations.csproj", "{766E3633-7B82-49CC-B012-CAE6264D4628}" @@ -175,8 +171,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B477B68A EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Utils.Ldap.Novell.Tests", "src\Utils\Ldap\Tests\Masa.Utils.Ldap.Novell.Tests\Masa.Utils.Ldap.Novell.Tests.csproj", "{023DE7BB-49B6-4C14-9DAC-F7B4E3E2D12C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Utils.Models.Config", "src\Utils\Models\Masa.Utils.Models.Config\Masa.Utils.Models.Config.csproj", "{41675E4A-0B1A-436B-910A-A296D35661DC}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Utils.Security.Cryptography", "src\Utils\Security\Masa.Utils.Security.Cryptography\Masa.Utils.Security.Cryptography.csproj", "{F43B5288-30F0-429E-A10F-9560E8CE318D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Masa.Utils.Security.Token", "src\Utils\Security\Masa.Utils.Security.Token\Masa.Utils.Security.Token.csproj", "{42A17DC6-7F8D-487A-98F0-1DAF6FF81A63}" @@ -861,14 +855,6 @@ Global {7B0EDB07-D3AE-4077-9A23-35CA6556E791}.Release|Any CPU.Build.0 = Release|Any CPU {7B0EDB07-D3AE-4077-9A23-35CA6556E791}.Release|x64.ActiveCfg = Release|Any CPU {7B0EDB07-D3AE-4077-9A23-35CA6556E791}.Release|x64.Build.0 = Release|Any CPU - {E376F15A-3C13-4DBF-B972-E03D2350D7C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E376F15A-3C13-4DBF-B972-E03D2350D7C4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E376F15A-3C13-4DBF-B972-E03D2350D7C4}.Debug|x64.ActiveCfg = Debug|Any CPU - {E376F15A-3C13-4DBF-B972-E03D2350D7C4}.Debug|x64.Build.0 = Debug|Any CPU - {E376F15A-3C13-4DBF-B972-E03D2350D7C4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E376F15A-3C13-4DBF-B972-E03D2350D7C4}.Release|Any CPU.Build.0 = Release|Any CPU - {E376F15A-3C13-4DBF-B972-E03D2350D7C4}.Release|x64.ActiveCfg = Release|Any CPU - {E376F15A-3C13-4DBF-B972-E03D2350D7C4}.Release|x64.Build.0 = Release|Any CPU {8AB652AF-3957-42F9-8F3E-FAFE56A44BE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8AB652AF-3957-42F9-8F3E-FAFE56A44BE1}.Debug|Any CPU.Build.0 = Debug|Any CPU {8AB652AF-3957-42F9-8F3E-FAFE56A44BE1}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -989,14 +975,6 @@ Global {023DE7BB-49B6-4C14-9DAC-F7B4E3E2D12C}.Release|Any CPU.Build.0 = Release|Any CPU {023DE7BB-49B6-4C14-9DAC-F7B4E3E2D12C}.Release|x64.ActiveCfg = Release|Any CPU {023DE7BB-49B6-4C14-9DAC-F7B4E3E2D12C}.Release|x64.Build.0 = Release|Any CPU - {41675E4A-0B1A-436B-910A-A296D35661DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {41675E4A-0B1A-436B-910A-A296D35661DC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {41675E4A-0B1A-436B-910A-A296D35661DC}.Debug|x64.ActiveCfg = Debug|Any CPU - {41675E4A-0B1A-436B-910A-A296D35661DC}.Debug|x64.Build.0 = Debug|Any CPU - {41675E4A-0B1A-436B-910A-A296D35661DC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {41675E4A-0B1A-436B-910A-A296D35661DC}.Release|Any CPU.Build.0 = Release|Any CPU - {41675E4A-0B1A-436B-910A-A296D35661DC}.Release|x64.ActiveCfg = Release|Any CPU - {41675E4A-0B1A-436B-910A-A296D35661DC}.Release|x64.Build.0 = Release|Any CPU {F43B5288-30F0-429E-A10F-9560E8CE318D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F43B5288-30F0-429E-A10F-9560E8CE318D}.Debug|Any CPU.Build.0 = Debug|Any CPU {F43B5288-30F0-429E-A10F-9560E8CE318D}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -2191,12 +2169,10 @@ Global {706DA866-6226-430F-AB4D-98FEE7B0DDB0} = {5944A182-13B8-4DA6-AEE2-0A01E64A9648} {69A6DFD9-F5A2-4714-94BA-36E85CDA3EF4} = {5944A182-13B8-4DA6-AEE2-0A01E64A9648} {0BC7A7F2-F8E0-4A6A-90E2-A0ACD997EBB1} = {5944A182-13B8-4DA6-AEE2-0A01E64A9648} - {9CABAF1C-E5E1-4CB8-AAD4-D47387EED6AA} = {5944A182-13B8-4DA6-AEE2-0A01E64A9648} {2D07F9AD-9951-475D-B7C7-980B23FDE9BB} = {5944A182-13B8-4DA6-AEE2-0A01E64A9648} {534346EF-1D11-48DB-9909-700CEC99FF08} = {2D07F9AD-9951-475D-B7C7-980B23FDE9BB} {015C4181-A8D9-4FA5-89B9-38A37FA9D31D} = {AF921AB1-64D1-4478-AB49-192F3EE416FC} {7B0EDB07-D3AE-4077-9A23-35CA6556E791} = {5944A182-13B8-4DA6-AEE2-0A01E64A9648} - {E376F15A-3C13-4DBF-B972-E03D2350D7C4} = {56917740-626B-42D5-8BB8-6895F79FB7D2} {8AB652AF-3957-42F9-8F3E-FAFE56A44BE1} = {56917740-626B-42D5-8BB8-6895F79FB7D2} {766E3633-7B82-49CC-B012-CAE6264D4628} = {706DA866-6226-430F-AB4D-98FEE7B0DDB0} {B7003322-212E-4568-9B61-95DB67CABC3F} = {706DA866-6226-430F-AB4D-98FEE7B0DDB0} @@ -2216,7 +2192,6 @@ Global {AE7980F2-6F94-4A93-9551-F47AD43FC545} = {0BC7A7F2-F8E0-4A6A-90E2-A0ACD997EBB1} {B477B68A-16F3-4005-BDAD-09905A3267A5} = {0BC7A7F2-F8E0-4A6A-90E2-A0ACD997EBB1} {023DE7BB-49B6-4C14-9DAC-F7B4E3E2D12C} = {B477B68A-16F3-4005-BDAD-09905A3267A5} - {41675E4A-0B1A-436B-910A-A296D35661DC} = {9CABAF1C-E5E1-4CB8-AAD4-D47387EED6AA} {F43B5288-30F0-429E-A10F-9560E8CE318D} = {2D07F9AD-9951-475D-B7C7-980B23FDE9BB} {42A17DC6-7F8D-487A-98F0-1DAF6FF81A63} = {2D07F9AD-9951-475D-B7C7-980B23FDE9BB} {386F0326-D591-4BED-A01A-91C0E9814467} = {534346EF-1D11-48DB-9909-700CEC99FF08} diff --git a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.csproj b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.csproj index bcac2ff6e..d93a20e6a 100644 --- a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.csproj +++ b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/IntegrationEventBus.cs b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/IntegrationEventBus.cs index d8661dcb5..84f432160 100644 --- a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/IntegrationEventBus.cs +++ b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/IntegrationEventBus.cs @@ -9,14 +9,14 @@ public class IntegrationEventBus : IIntegrationEventBus private readonly IPublisher _publisher; private readonly ILogger? _logger; private readonly IIntegrationEventLogService? _eventLogService; - private readonly IOptionsMonitor? _appConfig; + private readonly IOptionsMonitor? _masaAppConfigureOptions; private readonly IEventBus? _eventBus; private readonly IUnitOfWork? _unitOfWork; public IntegrationEventBus(IOptions options, IPublisher publisher, IIntegrationEventLogService? eventLogService = null, - IOptionsMonitor? appConfig = null, + IOptionsMonitor? masaAppConfigureOptions = null, ILogger? logger = null, IEventBus? eventBus = null, IUnitOfWork? unitOfWork = null) @@ -24,7 +24,7 @@ public IntegrationEventBus(IOptions options, _dispatcherOptions = options.Value; _publisher = publisher; _eventLogService = eventLogService; - _appConfig = appConfig; + _masaAppConfigureOptions = masaAppConfigureOptions; _logger = logger; _eventBus = eventBus; _unitOfWork = unitOfWork; @@ -71,7 +71,7 @@ private async Task PublishIntegrationAsync(TEvent @event) _logger?.LogDebug( "----- Publishing integration event: {IntegrationEventIdPublished} from {AppId} - ({IntegrationEvent})", @event.GetEventId(), - _appConfig?.CurrentValue.AppId ?? string.Empty, @event); + _masaAppConfigureOptions?.CurrentValue.AppId ?? string.Empty, @event); await _eventLogService.MarkEventAsInProgressAsync(@event.GetEventId()); @@ -83,7 +83,7 @@ private async Task PublishIntegrationAsync(TEvent @event) catch (Exception ex) { _logger?.LogError(ex, "Error Publishing integration event: {IntegrationEventId} from {AppId} - ({IntegrationEvent})", - @event.GetEventId(), _appConfig?.CurrentValue.AppId ?? string.Empty, @event); + @event.GetEventId(), _masaAppConfigureOptions?.CurrentValue.AppId ?? string.Empty, @event); if (!isAdd) throw; LocalQueueProcessor.Default.AddJobs(new IntegrationEventLogItem(@event.GetEventId(), @event.Topic, @event)); @@ -95,7 +95,7 @@ private async Task PublishIntegrationAsync(TEvent @event) _logger?.LogDebug( "----- Publishing integration event (don't use local message): {IntegrationEventIdPublished} from {AppId} - ({IntegrationEvent})", @event.GetEventId(), - _appConfig?.CurrentValue.AppId ?? string.Empty, @event); + _masaAppConfigureOptions?.CurrentValue.AppId ?? string.Empty, @event); await _publisher.PublishAsync(topicName, (dynamic)@event); } diff --git a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents.csproj b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents.csproj index 14b7bf1d2..18fe319d2 100644 --- a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents.csproj +++ b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents.csproj @@ -11,9 +11,9 @@ + - diff --git a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Processor/RetryByDataProcessor.cs b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Processor/RetryByDataProcessor.cs index e75b0da5e..070a07269 100644 --- a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Processor/RetryByDataProcessor.cs +++ b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Processor/RetryByDataProcessor.cs @@ -5,9 +5,8 @@ namespace Masa.Contrib.Dispatcher.IntegrationEvents.Processor; public class RetryByDataProcessor : ProcessorBase { - private readonly IServiceProvider _serviceProvider; private readonly IOptions _options; - private readonly IOptionsMonitor? _appConfig; + private readonly IOptionsMonitor? _masaAppConfigureOptions; private readonly ILogger? _logger; public override int Delay => _options.Value.FailedRetryInterval; @@ -15,11 +14,10 @@ public class RetryByDataProcessor : ProcessorBase public RetryByDataProcessor( IServiceProvider serviceProvider, IOptions options, - IOptionsMonitor? appConfig = null, + IOptionsMonitor? masaAppConfigureOptions = null, ILogger? logger = null) : base(serviceProvider) { - _serviceProvider = serviceProvider; - _appConfig = appConfig; + _masaAppConfigureOptions = masaAppConfigureOptions; _options = options; _logger = logger; } @@ -64,7 +62,7 @@ await eventLogService.RetrieveEventLogsFailedToPublishAsync(_options.Value.Retry { _logger?.LogError(ex, "Error Publishing integration event: {IntegrationEventId} from {AppId} - ({IntegrationEvent})", - eventLog.EventId, _appConfig?.CurrentValue.AppId ?? string.Empty, eventLog); + eventLog.EventId, _masaAppConfigureOptions?.CurrentValue.AppId ?? string.Empty, eventLog); await eventLogService.MarkEventAsFailedAsync(eventLog.EventId); } } diff --git a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Processor/RetryByLocalQueueProcessor.cs b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Processor/RetryByLocalQueueProcessor.cs index eca5e4715..d7a12c8d6 100644 --- a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Processor/RetryByLocalQueueProcessor.cs +++ b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/Processor/RetryByLocalQueueProcessor.cs @@ -5,7 +5,7 @@ namespace Masa.Contrib.Dispatcher.IntegrationEvents.Processor; public class RetryByLocalQueueProcessor : ProcessorBase { - private readonly IOptionsMonitor? _appConfig; + private readonly IOptionsMonitor? _masaAppConfigureOptions; private readonly IOptions _options; private readonly ILogger? _logger; @@ -14,10 +14,10 @@ public class RetryByLocalQueueProcessor : ProcessorBase public RetryByLocalQueueProcessor( IServiceProvider serviceProvider, IOptions options, - IOptionsMonitor? appConfig = null, + IOptionsMonitor? masaAppConfigureOptions = null, ILogger? logger = null) : base(serviceProvider) { - _appConfig = appConfig; + _masaAppConfigureOptions = masaAppConfigureOptions; _options = options; _logger = logger; } @@ -63,7 +63,7 @@ protected override async Task ExecuteAsync(IServiceProvider serviceProvider, Can { _logger?.LogError(ex, "Error Publishing integration event: {IntegrationEventId} from {AppId} - ({IntegrationEvent})", - eventLog.EventId, _appConfig?.CurrentValue.AppId ?? string.Empty, eventLog); + eventLog.EventId, _masaAppConfigureOptions?.CurrentValue.AppId ?? string.Empty, eventLog); await eventLogService.MarkEventAsFailedAsync(eventLog.EventId); } } diff --git a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/_Imports.cs b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/_Imports.cs index 06f358aeb..ddf4992fb 100644 --- a/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/_Imports.cs +++ b/src/Contrib/Dispatcher/IntegrationEvents/Masa.Contrib.Dispatcher.IntegrationEvents/_Imports.cs @@ -1,6 +1,7 @@ // Copyright (c) MASA Stack All rights reserved. // Licensed under the MIT License. See LICENSE.txt in the project root for license information. +global using Masa.BuildingBlocks.Configuration.Options; global using Masa.BuildingBlocks.Data; global using Masa.BuildingBlocks.Data.UoW; global using Masa.BuildingBlocks.Dispatcher.Events; @@ -11,7 +12,6 @@ global using Masa.Contrib.Dispatcher.IntegrationEvents.Options; global using Masa.Contrib.Dispatcher.IntegrationEvents.Processor; global using Masa.Contrib.Dispatcher.IntegrationEvents.Servers; -global using Masa.Utils.Models.Config; global using Microsoft.Extensions.DependencyInjection; global using Microsoft.Extensions.DependencyInjection.Extensions; global using Microsoft.Extensions.Hosting; diff --git a/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.Tests/IntegrationEventBusTest.cs b/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.Tests/IntegrationEventBusTest.cs index acaedac05..d1a7101e9 100644 --- a/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.Tests/IntegrationEventBusTest.cs +++ b/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.Tests/IntegrationEventBusTest.cs @@ -10,7 +10,7 @@ public class IntegrationEventBusTest private Mock _options; private Mock> _dispatcherOptions; private Mock _eventLog; - private Mock> _appConfig; + private Mock> _masaAppConfigureOptions; private Mock _uoW; [TestInitialize] @@ -27,8 +27,8 @@ public void Initialize() _eventLog.Setup(eventLog => eventLog.MarkEventAsInProgressAsync(It.IsAny())).Verifiable(); _eventLog.Setup(eventLog => eventLog.MarkEventAsPublishedAsync(It.IsAny())).Verifiable(); _eventLog.Setup(eventLog => eventLog.MarkEventAsFailedAsync(It.IsAny())).Verifiable(); - _appConfig = new(); - _appConfig.Setup(appConfig => appConfig.CurrentValue).Returns(() => new AppConfig() + _masaAppConfigureOptions = new(); + _masaAppConfigureOptions.Setup(appConfig => appConfig.CurrentValue).Returns(() => new MasaAppConfigureOptions { AppId = "Test" }); diff --git a/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.Tests/_Imports.cs b/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.Tests/_Imports.cs index 2b42073f5..ca7ac9b0a 100644 --- a/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.Tests/_Imports.cs +++ b/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.Tests/_Imports.cs @@ -1,6 +1,7 @@ // Copyright (c) MASA Stack All rights reserved. // Licensed under the MIT License. See LICENSE.txt in the project root for license information. +global using Masa.BuildingBlocks.Configuration.Options; global using Masa.BuildingBlocks.Data; global using Masa.BuildingBlocks.Data.UoW; global using Masa.BuildingBlocks.Dispatcher.Events; @@ -9,7 +10,6 @@ global using Masa.Contrib.Dispatcher.IntegrationEvents.Dapr.Options; global using Masa.Contrib.Dispatcher.IntegrationEvents.Processor; global using Masa.Contrib.Dispatcher.IntegrationEvents.Tests.Infrastructure; -global using Masa.Utils.Models.Config; global using Microsoft.Extensions.DependencyInjection; global using Microsoft.Extensions.Options; global using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/IntegrationEventBusTest.cs b/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/IntegrationEventBusTest.cs index 6eac8fd5f..d411abea5 100644 --- a/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/IntegrationEventBusTest.cs +++ b/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/IntegrationEventBusTest.cs @@ -11,7 +11,7 @@ public class IntegrationEventBusTest private Mock _publisher; private Mock> _logger; private Mock _eventLog; - private Mock> _appConfig; + private Mock> _masaAppConfigureOptions; private Mock _eventBus; private Mock _uoW; @@ -31,8 +31,8 @@ public void Initialize() _eventLog.Setup(eventLog => eventLog.MarkEventAsInProgressAsync(It.IsAny())).Verifiable(); _eventLog.Setup(eventLog => eventLog.MarkEventAsPublishedAsync(It.IsAny())).Verifiable(); _eventLog.Setup(eventLog => eventLog.MarkEventAsFailedAsync(It.IsAny())).Verifiable(); - _appConfig = new(); - _appConfig.Setup(appConfig => appConfig.CurrentValue).Returns(() => new AppConfig() + _masaAppConfigureOptions = new(); + _masaAppConfigureOptions.Setup(masaAppConfigureOptions => masaAppConfigureOptions.CurrentValue).Returns(() => new MasaAppConfigureOptions() { AppId = "Test" }); @@ -71,7 +71,7 @@ public async Task TestPublishIntegrationEventAsync() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, _logger.Object, _eventBus.Object, _uoW.Object); @@ -95,7 +95,7 @@ public async Task TestNotUseUoWAndLoggerAsync() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, null, _eventBus.Object); RegisterUserIntegrationEvent @event = new RegisterUserIntegrationEvent() @@ -122,7 +122,7 @@ public async Task TestNotUseTransactionAsync() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, _logger.Object, _eventBus.Object, _uoW.Object); @@ -149,7 +149,7 @@ public async Task TestUseTranscationAndNotUseLoggerAsync() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, null, _eventBus.Object, _uoW.Object); @@ -178,7 +178,7 @@ public async Task TestSaveEventFailedAndNotUseLoggerAsync() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, null, _eventBus.Object, _uoW.Object); @@ -199,7 +199,7 @@ public async Task TestPublishIntegrationEventAndFailedAsync() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, _logger.Object, _eventBus.Object, _uoW.Object); @@ -227,7 +227,7 @@ public async Task TestPublishIntegrationEventAndNotUoWAsync() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, _logger.Object, _eventBus.Object, _uoW.Object); @@ -253,7 +253,7 @@ public async Task TestPublishEventAsync() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, _logger.Object, _eventBus.Object, _uoW.Object); @@ -273,7 +273,7 @@ public async Task TestPublishEventAndNotEventBusAsync() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, _logger.Object, null, _uoW.Object); @@ -294,7 +294,7 @@ public async Task TestCommitAsync() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, _logger.Object, _eventBus.Object, _uoW.Object); @@ -310,7 +310,7 @@ public async Task TestNotUseUowCommitAsync() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, _logger.Object, _eventBus.Object, null); @@ -328,7 +328,7 @@ public void TestGetAllEventTypes() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, _logger.Object, null, null); @@ -352,7 +352,7 @@ public void TestUseEventBusGetAllEventTypes() _dispatcherOptions.Object, _publisher.Object, _eventLog.Object, - _appConfig.Object, + _masaAppConfigureOptions.Object, _logger.Object, _eventBus.Object, null); diff --git a/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/ProcessorTest.cs b/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/ProcessorTest.cs index a2b26ac9b..30b851977 100644 --- a/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/ProcessorTest.cs +++ b/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/ProcessorTest.cs @@ -1,9 +1,6 @@ // Copyright (c) MASA Stack All rights reserved. // Licensed under the MIT License. See LICENSE.txt in the project root for license information. -using Masa.Contrib.Dispatcher.IntegrationEvents.Tests.Events; -using Masa.Contrib.Dispatcher.IntegrationEvents.Tests.Infrastructure; - namespace Masa.Contrib.Dispatcher.IntegrationEvents.Tests; [TestClass] @@ -96,7 +93,7 @@ public async Task RetryByDataProcessorExecuteTestAsync() Mock> options = new(); options.Setup(opt => opt.Value).Returns(new DispatcherOptions(services, AppDomain.CurrentDomain.GetAssemblies())); - AppConfig appConfig = new() + MasaAppConfigureOptions masaAppConfigureOptions = new() { AppId = "test" }; @@ -105,7 +102,7 @@ public async Task RetryByDataProcessorExecuteTestAsync() RetryByDataProcessor retryByDataProcessor = new( serviceProvider, options.Object, - Mock.Of>(a => a.CurrentValue == appConfig), + Mock.Of>(a => a.CurrentValue == masaAppConfigureOptions), serviceProvider.GetService>()); await retryByDataProcessor.ExecuteAsync(cancellationTokenSource.Token); @@ -175,7 +172,7 @@ public async Task RetryByDataProcessorExecute2TestAsync() Mock> options = new(); options.Setup(opt => opt.Value).Returns(new DispatcherOptions(services, AppDomain.CurrentDomain.GetAssemblies())); - AppConfig appConfig = new() + MasaAppConfigureOptions masaAppConfigureOptions = new() { AppId = "test" }; @@ -184,7 +181,7 @@ public async Task RetryByDataProcessorExecute2TestAsync() RetryByDataProcessor retryByDataProcessor = new( serviceProvider, options.Object, - Mock.Of>(a => a.CurrentValue == appConfig), + Mock.Of>(a => a.CurrentValue == masaAppConfigureOptions), serviceProvider.GetService>()); await retryByDataProcessor.ExecuteAsync(cancellationTokenSource.Token); @@ -237,7 +234,7 @@ public async Task RetryByDataProcessorExecute2AndNotUseLoggerTestAsync() Mock> options = new(); options.Setup(opt => opt.Value).Returns(new DispatcherOptions(services, AppDomain.CurrentDomain.GetAssemblies())); - AppConfig appConfig = new() + MasaAppConfigureOptions masaAppConfigureOptions = new() { AppId = "test" }; @@ -263,7 +260,7 @@ public async Task RetryByDataProcessorExecute2AndNotUseLoggerTestAsync() RetryByDataProcessor retryByDataProcessor = new( serviceProvider, options.Object, - Mock.Of>(a => a.CurrentValue == appConfig), + Mock.Of>(a => a.CurrentValue == masaAppConfigureOptions), serviceProvider.GetService>()); await retryByDataProcessor.ExecuteAsync(cancellationTokenSource.Token); diff --git a/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/_Imports.cs b/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/_Imports.cs index 2f24d8931..c15c89abc 100644 --- a/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/_Imports.cs +++ b/src/Contrib/Dispatcher/IntegrationEvents/Tests/Masa.Contrib.Dispatcher.IntegrationEvents.Tests/_Imports.cs @@ -1,6 +1,7 @@ // Copyright (c) MASA Stack All rights reserved. // Licensed under the MIT License. See LICENSE.txt in the project root for license information. +global using Masa.BuildingBlocks.Configuration.Options; global using Masa.BuildingBlocks.Data; global using Masa.BuildingBlocks.Data.UoW; global using Masa.BuildingBlocks.Dispatcher.Events; @@ -10,7 +11,6 @@ global using Masa.Contrib.Dispatcher.IntegrationEvents.Processor; global using Masa.Contrib.Dispatcher.IntegrationEvents.Tests.Events; global using Masa.Contrib.Dispatcher.IntegrationEvents.Tests.Infrastructure; -global using Masa.Utils.Models.Config; global using Microsoft.Extensions.DependencyInjection; global using Microsoft.Extensions.DependencyInjection.Extensions; global using Microsoft.Extensions.Logging; diff --git a/src/Contrib/Dispatcher/Masa.Contrib.Dispatcher.Events/Masa.Contrib.Dispatcher.Events.csproj b/src/Contrib/Dispatcher/Masa.Contrib.Dispatcher.Events/Masa.Contrib.Dispatcher.Events.csproj index d6bfc36ec..dff3fedda 100644 --- a/src/Contrib/Dispatcher/Masa.Contrib.Dispatcher.Events/Masa.Contrib.Dispatcher.Events.csproj +++ b/src/Contrib/Dispatcher/Masa.Contrib.Dispatcher.Events/Masa.Contrib.Dispatcher.Events.csproj @@ -17,7 +17,6 @@ - diff --git a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/Masa.Contrib.StackSdks.Dcc.csproj b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/Masa.Contrib.StackSdks.Dcc.csproj index fe3fbe0a1..2d64adc55 100644 --- a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/Masa.Contrib.StackSdks.Dcc.csproj +++ b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/Masa.Contrib.StackSdks.Dcc.csproj @@ -9,7 +9,6 @@ - diff --git a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/ServiceCollectionExtensions.cs b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/ServiceCollectionExtensions.cs index acf37dc48..3b05eb622 100644 --- a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/ServiceCollectionExtensions.cs +++ b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/ServiceCollectionExtensions.cs @@ -2,21 +2,21 @@ // Licensed under the MIT License. See LICENSE.txt in the project root for license information. // ReSharper disable once CheckNamespace + namespace Microsoft.Extensions.DependencyInjection; public static class ServiceCollectionExtensions { - public static void AddDccClient(this IServiceCollection services) + public static void AddDccClient(this IServiceCollection services, string sectionName = "DccOptions") { - var redisConfigurationOptions = AppSettings.GetModel("DccOptions:RedisOptions"); - services.AddDccClient(redisConfigurationOptions); + services.AddConfigure($"{sectionName}:RedisOptions", DEFAULT_CLIENT_NAME); + services.AddDccClientCore(); } public static void AddDccClient(this IServiceCollection services, Action options) { - var redisConfigurationOptions = new RedisConfigurationOptions(); - options.Invoke(redisConfigurationOptions); - services.AddDccClient(redisConfigurationOptions); + services.Configure(DEFAULT_CLIENT_NAME, options); + services.AddDccClientCore(); } public static void AddDccClient(this IServiceCollection services, RedisConfigurationOptions options) @@ -26,6 +26,17 @@ public static void AddDccClient(this IServiceCollection services, RedisConfigura distributedCacheOptions.UseStackExchangeRedisCache(options); }); + services.AddDccClientCore(false); + } + + private static void AddDccClientCore(this IServiceCollection services, bool isUseStackExchangeRedisCache = true) + { + if (isUseStackExchangeRedisCache) + services.AddDistributedCache(DEFAULT_CLIENT_NAME, distributedCacheOptions => + { + distributedCacheOptions.UseStackExchangeRedisCache(); + }); + services.AddSingleton(serviceProvider => { var client = serviceProvider.GetRequiredService().Create(DEFAULT_CLIENT_NAME); diff --git a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/_Imports.cs b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/_Imports.cs index 839eb44c7..cc241b80c 100644 --- a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/_Imports.cs +++ b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Dcc/_Imports.cs @@ -9,5 +9,4 @@ global using Masa.Contrib.Caching.Distributed.StackExchangeRedis; global using Masa.Contrib.StackSdks.Dcc; global using Masa.Contrib.StackSdks.Dcc.Service; -global using Masa.Utils.Configuration.Json; global using static Masa.Contrib.StackSdks.Dcc.Internal.Constants; diff --git a/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/DccClientTest.cs b/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/DccClientTest.cs index fe85d35f9..36751110f 100644 --- a/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/DccClientTest.cs +++ b/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/DccClientTest.cs @@ -20,12 +20,17 @@ public void TestAddDccClient() [TestMethod] public void TestAddDccClient2() { - var services = new ServiceCollection(); - var options = AppSettings.GetModel("DccOptions:RedisOptions"); - - services.AddDccClient(options); - - var dccClient = services.BuildServiceProvider().GetRequiredService(); + var builder = WebApplication.CreateBuilder(); + builder.Services.AddDccClient(); + var serviceProvider = builder.Services.BuildServiceProvider(); + var options = serviceProvider.GetRequiredService>(); + var redisOptions = options.Get("masa.contrib.basicability.dcc"); + Assert.AreEqual(1, redisOptions.Servers.Count); + Assert.AreEqual("localhost", redisOptions.Servers[0].Host); + Assert.AreEqual(8888, redisOptions.Servers[0].Port); + Assert.AreEqual(0, redisOptions.DefaultDatabase); + + var dccClient = serviceProvider.GetRequiredService(); Assert.IsNotNull(dccClient); } diff --git a/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/Masa.Contrib.StackSdks.Dcc.Tests.csproj b/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/Masa.Contrib.StackSdks.Dcc.Tests.csproj index 34e599e58..f0e05c000 100644 --- a/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/Masa.Contrib.StackSdks.Dcc.Tests.csproj +++ b/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/Masa.Contrib.StackSdks.Dcc.Tests.csproj @@ -8,7 +8,11 @@ - + + + + + @@ -18,10 +22,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -33,7 +37,7 @@ - + diff --git a/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/_Imports.cs b/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/_Imports.cs index 7fd27ccf8..3cccd1ff3 100644 --- a/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/_Imports.cs +++ b/src/Contrib/StackSdks/Tests/Masa.Contrib.StackSdks.Dcc.Tests/_Imports.cs @@ -5,7 +5,8 @@ global using Masa.BuildingBlocks.StackSdks.Dcc; global using Masa.BuildingBlocks.StackSdks.Dcc.Contracts.Model; global using Masa.Contrib.Caching.Distributed.StackExchangeRedis; -global using Masa.Utils.Configuration.Json; +global using Microsoft.AspNetCore.Builder; global using Microsoft.Extensions.DependencyInjection; +global using Microsoft.Extensions.Options; global using Microsoft.VisualStudio.TestTools.UnitTesting; global using Moq; diff --git a/src/Utils/Configuration/Masa.Utils.Configuration.Dcc/Masa.Utils.Configuration.Dcc.csproj b/src/Utils/Configuration/Masa.Utils.Configuration.Dcc/Masa.Utils.Configuration.Dcc.csproj deleted file mode 100644 index 132c02c59..000000000 --- a/src/Utils/Configuration/Masa.Utils.Configuration.Dcc/Masa.Utils.Configuration.Dcc.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net6.0 - enable - enable - - - diff --git a/src/Utils/Models/Masa.Utils.Models.Config/AppConfig.cs b/src/Utils/Models/Masa.Utils.Models.Config/AppConfig.cs deleted file mode 100644 index 1206141a7..000000000 --- a/src/Utils/Models/Masa.Utils.Models.Config/AppConfig.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) MASA Stack All rights reserved. -// Licensed under the MIT License. See LICENSE.txt in the project root for license information. - -namespace Masa.Utils.Models.Config; - -public class AppConfig -{ - public string AppId { get; set; } = string.Empty; -} diff --git a/src/Utils/Models/Masa.Utils.Models.Config/Masa.Utils.Models.Config.csproj b/src/Utils/Models/Masa.Utils.Models.Config/Masa.Utils.Models.Config.csproj deleted file mode 100644 index 132c02c59..000000000 --- a/src/Utils/Models/Masa.Utils.Models.Config/Masa.Utils.Models.Config.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net6.0 - enable - enable - - - diff --git a/src/Utils/Models/Masa.Utils.Models.Config/_Imports.cs b/src/Utils/Models/Masa.Utils.Models.Config/_Imports.cs deleted file mode 100644 index d2670a845..000000000 --- a/src/Utils/Models/Masa.Utils.Models.Config/_Imports.cs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) MASA Stack All rights reserved. -// Licensed under the MIT License. See LICENSE.txt in the project root for license information. - -global using System.Reflection;