@@ -38,7 +38,7 @@ namespace Microsoft.Extensions.DependencyInjection | |||||
services.TryAddSingleton<ICapPublisher, CapPublisher>(); | services.TryAddSingleton<ICapPublisher, CapPublisher>(); | ||||
services.TryAddSingleton<IConsumerServiceSelector, DefaultConsumerServiceSelector>(); | |||||
services.TryAddSingleton<IConsumerServiceSelector, ConsumerServiceSelector>(); | |||||
services.TryAddSingleton<ISubscribeInvokerFactory, ConsumerInvokerFactory>(); | services.TryAddSingleton<ISubscribeInvokerFactory, ConsumerInvokerFactory>(); | ||||
services.TryAddSingleton<MethodMatcherCache>(); | services.TryAddSingleton<MethodMatcherCache>(); | ||||
@@ -60,7 +60,7 @@ namespace Microsoft.Extensions.DependencyInjection | |||||
services.TryAddSingleton<ISerializer, JsonUtf8Serializer>(); | services.TryAddSingleton<ISerializer, JsonUtf8Serializer>(); | ||||
// Warning: IPublishMessageSender need to inject at extension project. | // Warning: IPublishMessageSender need to inject at extension project. | ||||
services.TryAddSingleton<ISubscribeDispatcher, DefaultSubscribeDispatcher>(); | |||||
services.TryAddSingleton<ISubscribeDispatcher, SubscribeDispatcher>(); | |||||
//Options and extension service | //Options and extension service | ||||
var options = new CapOptions(); | var options = new CapOptions(); | ||||
@@ -72,7 +72,7 @@ namespace Microsoft.Extensions.DependencyInjection | |||||
services.Configure(setupAction); | services.Configure(setupAction); | ||||
//Startup and Hosted | //Startup and Hosted | ||||
services.AddHostedService<DefaultBootstrapper>(); | |||||
services.AddHostedService<Bootstrapper>(); | |||||
return new CapBuilder(services); | return new CapBuilder(services); | ||||
} | } | ||||
@@ -21,7 +21,7 @@ namespace DotNetCore.CAP.Internal | |||||
public ISubscribeInvoker CreateInvoker() | public ISubscribeInvoker CreateInvoker() | ||||
{ | { | ||||
return new DefaultSubscribeInvoker(_loggerFactory, _serviceProvider); | |||||
return new SubscribeInvoker(_loggerFactory, _serviceProvider); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -14,12 +14,12 @@ namespace DotNetCore.CAP.Internal | |||||
/// <summary> | /// <summary> | ||||
/// Default implement of <see cref="T:DotNetCore.CAP.Internal.IBootstrapper" />. | /// Default implement of <see cref="T:DotNetCore.CAP.Internal.IBootstrapper" />. | ||||
/// </summary> | /// </summary> | ||||
internal class DefaultBootstrapper : BackgroundService, IBootstrapper | |||||
internal class Bootstrapper : BackgroundService, IBootstrapper | |||||
{ | { | ||||
private readonly ILogger<DefaultBootstrapper> _logger; | |||||
private readonly ILogger<Bootstrapper> _logger; | |||||
public DefaultBootstrapper( | |||||
ILogger<DefaultBootstrapper> logger, | |||||
public Bootstrapper( | |||||
ILogger<Bootstrapper> logger, | |||||
IStorageInitializer storage, | IStorageInitializer storage, | ||||
IEnumerable<IProcessingServer> processors) | IEnumerable<IProcessingServer> processors) | ||||
{ | { | ||||
@@ -16,7 +16,7 @@ namespace DotNetCore.CAP.Internal | |||||
/// <summary> | /// <summary> | ||||
/// A default <see cref="T:DotNetCore.CAP.Abstractions.IConsumerServiceSelector" /> implementation. | /// A default <see cref="T:DotNetCore.CAP.Abstractions.IConsumerServiceSelector" /> implementation. | ||||
/// </summary> | /// </summary> | ||||
public class DefaultConsumerServiceSelector : IConsumerServiceSelector | |||||
public class ConsumerServiceSelector : IConsumerServiceSelector | |||||
{ | { | ||||
private readonly CapOptions _capOptions; | private readonly CapOptions _capOptions; | ||||
private readonly IServiceProvider _serviceProvider; | private readonly IServiceProvider _serviceProvider; | ||||
@@ -28,9 +28,9 @@ namespace DotNetCore.CAP.Internal | |||||
private readonly ConcurrentDictionary<string, List<RegexExecuteDescriptor<ConsumerExecutorDescriptor>>> _poundList; | private readonly ConcurrentDictionary<string, List<RegexExecuteDescriptor<ConsumerExecutorDescriptor>>> _poundList; | ||||
/// <summary> | /// <summary> | ||||
/// Creates a new <see cref="DefaultConsumerServiceSelector" />. | |||||
/// Creates a new <see cref="ConsumerServiceSelector" />. | |||||
/// </summary> | /// </summary> | ||||
public DefaultConsumerServiceSelector(IServiceProvider serviceProvider) | |||||
public ConsumerServiceSelector(IServiceProvider serviceProvider) | |||||
{ | { | ||||
_serviceProvider = serviceProvider; | _serviceProvider = serviceProvider; | ||||
_capOptions = serviceProvider.GetService<IOptions<CapOptions>>().Value; | _capOptions = serviceProvider.GetService<IOptions<CapOptions>>().Value; | ||||
@@ -17,7 +17,7 @@ using Microsoft.Extensions.Options; | |||||
namespace DotNetCore.CAP.Internal | namespace DotNetCore.CAP.Internal | ||||
{ | { | ||||
internal class DefaultSubscribeDispatcher : ISubscribeDispatcher | |||||
internal class SubscribeDispatcher : ISubscribeDispatcher | |||||
{ | { | ||||
private readonly IDataStorage _dataStorage; | private readonly IDataStorage _dataStorage; | ||||
private readonly ILogger _logger; | private readonly ILogger _logger; | ||||
@@ -29,8 +29,8 @@ namespace DotNetCore.CAP.Internal | |||||
private static readonly DiagnosticListener s_diagnosticListener = | private static readonly DiagnosticListener s_diagnosticListener = | ||||
new DiagnosticListener(CapDiagnosticListenerNames.DiagnosticListenerName); | new DiagnosticListener(CapDiagnosticListenerNames.DiagnosticListenerName); | ||||
public DefaultSubscribeDispatcher( | |||||
ILogger<DefaultSubscribeDispatcher> logger, | |||||
public SubscribeDispatcher( | |||||
ILogger<SubscribeDispatcher> logger, | |||||
IOptions<CapOptions> options, | IOptions<CapOptions> options, | ||||
IServiceProvider provider) | IServiceProvider provider) | ||||
{ | { | ||||
@@ -12,15 +12,15 @@ using Microsoft.Extensions.Logging; | |||||
namespace DotNetCore.CAP.Internal | namespace DotNetCore.CAP.Internal | ||||
{ | { | ||||
internal class DefaultSubscribeInvoker : ISubscribeInvoker | |||||
internal class SubscribeInvoker : ISubscribeInvoker | |||||
{ | { | ||||
private readonly ILogger _logger; | private readonly ILogger _logger; | ||||
private readonly IServiceProvider _serviceProvider; | private readonly IServiceProvider _serviceProvider; | ||||
public DefaultSubscribeInvoker(ILoggerFactory loggerFactory, IServiceProvider serviceProvider) | |||||
public SubscribeInvoker(ILoggerFactory loggerFactory, IServiceProvider serviceProvider) | |||||
{ | { | ||||
_serviceProvider = serviceProvider; | _serviceProvider = serviceProvider; | ||||
_logger = loggerFactory.CreateLogger<DefaultSubscribeInvoker>(); | |||||
_logger = loggerFactory.CreateLogger<SubscribeInvoker>(); | |||||
} | } | ||||
public async Task<ConsumerExecutedResult> InvokeAsync(ConsumerContext context, CancellationToken cancellationToken = default) | public async Task<ConsumerExecutedResult> InvokeAsync(ConsumerContext context, CancellationToken cancellationToken = default) | ||||
@@ -30,7 +30,7 @@ namespace DotNetCore.CAP.Internal | |||||
_logger.LogDebug("Executing subscriber method : {0}", context.ConsumerDescriptor.MethodInfo.Name); | _logger.LogDebug("Executing subscriber method : {0}", context.ConsumerDescriptor.MethodInfo.Name); | ||||
var executor = ObjectMethodExecutor.Create( | var executor = ObjectMethodExecutor.Create( | ||||
context.ConsumerDescriptor.MethodInfo, | |||||
context.ConsumerDescriptor.MethodInfo, | |||||
context.ConsumerDescriptor.ImplTypeInfo); | context.ConsumerDescriptor.ImplTypeInfo); | ||||
using (var scope = _serviceProvider.CreateScope()) | using (var scope = _serviceProvider.CreateScope()) | ||||
@@ -16,7 +16,7 @@ namespace DotNetCore.CAP.Test | |||||
ServiceCollectionExtensions.ServiceCollection = services; | ServiceCollectionExtensions.ServiceCollection = services; | ||||
services.AddOptions(); | services.AddOptions(); | ||||
services.PostConfigure<CapOptions>(x=>{}); | services.PostConfigure<CapOptions>(x=>{}); | ||||
services.AddSingleton<IConsumerServiceSelector, DefaultConsumerServiceSelector>(); | |||||
services.AddSingleton<IConsumerServiceSelector, ConsumerServiceSelector>(); | |||||
services.AddScoped<IFooTest, CandidatesFooTest>(); | services.AddScoped<IFooTest, CandidatesFooTest>(); | ||||
services.AddScoped<IBarTest, CandidatesBarTest>(); | services.AddScoped<IBarTest, CandidatesBarTest>(); | ||||
services.AddLogging(); | services.AddLogging(); | ||||
@@ -46,7 +46,7 @@ namespace DotNetCore.CAP.Test | |||||
} | } | ||||
} | } | ||||
public class MyConsumerServiceSelector : DefaultConsumerServiceSelector | |||||
public class MyConsumerServiceSelector : ConsumerServiceSelector | |||||
{ | { | ||||
private readonly CapOptions _capOptions; | private readonly CapOptions _capOptions; | ||||
@@ -9,15 +9,15 @@ using Xunit; | |||||
namespace DotNetCore.CAP.Test | namespace DotNetCore.CAP.Test | ||||
{ | { | ||||
public class ConsumerInvokerTest | |||||
public class SubscribeInvokerTest | |||||
{ | { | ||||
private readonly IServiceProvider _serviceProvider; | private readonly IServiceProvider _serviceProvider; | ||||
public ConsumerInvokerTest() | |||||
public SubscribeInvokerTest() | |||||
{ | { | ||||
var serviceCollection = new ServiceCollection(); | var serviceCollection = new ServiceCollection(); | ||||
serviceCollection.AddLogging(); | serviceCollection.AddLogging(); | ||||
serviceCollection.AddSingleton<ISubscribeInvoker, DefaultSubscribeInvoker>(); | |||||
serviceCollection.AddSingleton<ISubscribeInvoker, SubscribeInvoker>(); | |||||
_serviceProvider = serviceCollection.BuildServiceProvider(); | _serviceProvider = serviceCollection.BuildServiceProvider(); | ||||
} | } | ||||