Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
904a6933
Commit
904a6933
authored
May 01, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
parent
966f605b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
ConsumerExcutorSelector.cs
src/Cap.Consistency/Internal/ConsumerExcutorSelector.cs
+13
-6
No files found.
src/Cap.Consistency/Internal/ConsumerExcutorSelector.cs
View file @
904a6933
...
...
@@ -14,13 +14,16 @@ namespace Cap.Consistency.Internal
{
public
class
ConsumerExcutorSelector
:
IConsumerExcutorSelector
{
public
ConsumerExecutorDescriptor
SelectBestCandidate
(
TopicRouteContext
context
,
IReadOnlyList
<
ConsumerExecutorDescriptor
>
executeDescriptor
)
{
private
readonly
IServiceProvider
_serviceProvider
;
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
);
}
public
IReadOnlyList
<
ConsumerExecutorDescriptor
>
SelectCandidates
(
TopicRouteContext
context
)
{
var
consumerServices
=
context
.
ServiceProvider
.
GetServices
<
IConsumerService
>();
...
...
@@ -37,16 +40,20 @@ namespace Cap.Consistency.Internal
var
topicAttr
=
method
.
GetCustomAttribute
<
TopicAttribute
>(
true
);
if
(
topicAttr
==
null
)
continue
;
executorDescriptorList
.
Add
(
InitDescriptor
(
topicAttr
));
executorDescriptorList
.
Add
(
InitDescriptor
(
topicAttr
,
method
,
typeInfo
));
}
}
return
executorDescriptorList
;
}
private
ConsumerExecutorDescriptor
InitDescriptor
(
TopicAttribute
attr
)
{
private
ConsumerExecutorDescriptor
InitDescriptor
(
TopicAttribute
attr
,
MethodInfo
methodInfo
,
TypeInfo
implType
)
{
var
descriptor
=
new
ConsumerExecutorDescriptor
();
descriptor
.
Topic
=
new
TopicInfo
(
attr
.
Name
);
descriptor
.
MethodInfo
=
methodInfo
;
descriptor
.
ImplTypeInfo
=
implType
;
return
descriptor
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment