Browse Source

Merge branch 'dev_2.0' of https://github.com/dotnetcore/CAP into dev_2.0

master
Savorboard 7 years ago
parent
commit
5c82ba1d7e
5 changed files with 10 additions and 12 deletions
  1. +2
    -3
      src/DotNetCore.CAP/Abstractions/IConsumerServiceSelector.cs
  2. +1
    -1
      src/DotNetCore.CAP/IConsumerHandler.Default.cs
  3. +3
    -3
      src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs
  4. +2
    -3
      src/DotNetCore.CAP/Internal/MethodMatcherCache.cs
  5. +2
    -2
      test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs

+ 2
- 3
src/DotNetCore.CAP/Abstractions/IConsumerServiceSelector.cs View File

@@ -11,10 +11,9 @@ namespace DotNetCore.CAP.Abstractions
/// <summary>
/// Selects a set of <see cref="ConsumerExecutorDescriptor"/> candidates for the current message associated with
/// <paramref name="provider"/>.
/// </summary>
/// <param name="provider"> <see cref="IServiceProvider"/>.</param>
/// </summary>
/// <returns>A set of <see cref="ConsumerExecutorDescriptor"/> candidates or <c>null</c>.</returns>
IReadOnlyList<ConsumerExecutorDescriptor> SelectCandidates(IServiceProvider provider);
IReadOnlyList<ConsumerExecutorDescriptor> SelectCandidates();

/// <summary>
/// Selects the best <see cref="ConsumerExecutorDescriptor"/> candidate from <paramref name="candidates"/> for the


+ 1
- 1
src/DotNetCore.CAP/IConsumerHandler.Default.cs View File

@@ -47,7 +47,7 @@ namespace DotNetCore.CAP

public void Start()
{
var groupingMatchs = _selector.GetCandidatesMethodsOfGroupNameGrouped(_serviceProvider);
var groupingMatchs = _selector.GetCandidatesMethodsOfGroupNameGrouped();

foreach (var matchGroup in groupingMatchs)
{


+ 3
- 3
src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs View File

@@ -33,13 +33,13 @@ namespace DotNetCore.CAP.Internal
return executeDescriptor.FirstOrDefault(x => x.Attribute.Name == key);
}

public IReadOnlyList<ConsumerExecutorDescriptor> SelectCandidates(IServiceProvider provider)
public IReadOnlyList<ConsumerExecutorDescriptor> SelectCandidates()
{
var executorDescriptorList = new List<ConsumerExecutorDescriptor>();

executorDescriptorList.AddRange(FindConsumersFromInterfaceTypes(provider));
executorDescriptorList.AddRange(FindConsumersFromInterfaceTypes(_serviceProvider));

executorDescriptorList.AddRange(FindConsumersFromControllerTypes(provider));
executorDescriptorList.AddRange(FindConsumersFromControllerTypes(_serviceProvider));

return executorDescriptorList;
}


+ 2
- 3
src/DotNetCore.CAP/Internal/MethodMatcherCache.cs View File

@@ -22,12 +22,11 @@ namespace DotNetCore.CAP.Internal
/// Get a dictionary of candidates.In the dictionary,
/// the Key is the CAPSubscribeAttribute Group, the Value for the current Group of candidates
/// </summary>
/// <param name="provider"><see cref="IServiceProvider"/></param>
public ConcurrentDictionary<string, IList<ConsumerExecutorDescriptor>> GetCandidatesMethodsOfGroupNameGrouped(IServiceProvider provider)
public ConcurrentDictionary<string, IList<ConsumerExecutorDescriptor>> GetCandidatesMethodsOfGroupNameGrouped()
{
if (Entries.Count != 0) return Entries;

var executorCollection = _selector.SelectCandidates(provider);
var executorCollection = _selector.SelectCandidates();

var groupedCandidates = executorCollection.GroupBy(x => x.Attribute.Group);



+ 2
- 2
test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs View File

@@ -25,7 +25,7 @@ namespace DotNetCore.CAP.Test
public void CanFindAllConsumerService()
{
var selector = _provider.GetRequiredService<IConsumerServiceSelector>();
var candidates = selector.SelectCandidates(_provider);
var candidates = selector.SelectCandidates();

Assert.Equal(2, candidates.Count);
}
@@ -34,7 +34,7 @@ namespace DotNetCore.CAP.Test
public void CanFindSpecifiedTopic()
{
var selector = _provider.GetRequiredService<IConsumerServiceSelector>();
var candidates = selector.SelectCandidates(_provider);
var candidates = selector.SelectCandidates();
var bestCandidates = selector.SelectBestCandidate("Candidates.Foo", candidates);

Assert.NotNull(bestCandidates);


Loading…
Cancel
Save