Commit 904a6933 authored by yangxiaodong's avatar yangxiaodong

refactor

parent 966f605b
...@@ -14,10 +14,13 @@ namespace Cap.Consistency.Internal ...@@ -14,10 +14,13 @@ namespace Cap.Consistency.Internal
{ {
public class ConsumerExcutorSelector : IConsumerExcutorSelector public class ConsumerExcutorSelector : IConsumerExcutorSelector
{ {
public ConsumerExecutorDescriptor SelectBestCandidate(TopicRouteContext context, private readonly IServiceProvider _serviceProvider;
IReadOnlyList<ConsumerExecutorDescriptor> executeDescriptor) {
var key = context.Message.MessageKey; public ConsumerExcutorSelector(IServiceProvider serviceProvider) {
_serviceProvider = serviceProvider;
}
public ConsumerExecutorDescriptor SelectBestCandidate(string key, IReadOnlyList<ConsumerExecutorDescriptor> executeDescriptor) {
return executeDescriptor.FirstOrDefault(x => x.Topic.Name == key); return executeDescriptor.FirstOrDefault(x => x.Topic.Name == key);
} }
...@@ -37,16 +40,20 @@ namespace Cap.Consistency.Internal ...@@ -37,16 +40,20 @@ namespace Cap.Consistency.Internal
var topicAttr = method.GetCustomAttribute<TopicAttribute>(true); var topicAttr = method.GetCustomAttribute<TopicAttribute>(true);
if (topicAttr == null) continue; if (topicAttr == null) continue;
executorDescriptorList.Add(InitDescriptor(topicAttr)); executorDescriptorList.Add(InitDescriptor(topicAttr, method, typeInfo));
} }
} }
return executorDescriptorList; return executorDescriptorList;
} }
private ConsumerExecutorDescriptor InitDescriptor(TopicAttribute attr) { private ConsumerExecutorDescriptor InitDescriptor(TopicAttribute attr,
MethodInfo methodInfo, TypeInfo implType
) {
var descriptor = new ConsumerExecutorDescriptor(); var descriptor = new ConsumerExecutorDescriptor();
descriptor.Topic = new TopicInfo(attr.Name); descriptor.Topic = new TopicInfo(attr.Name);
descriptor.MethodInfo = methodInfo;
descriptor.ImplTypeInfo = implType;
return descriptor; return descriptor;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment