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
019baee2
Commit
019baee2
authored
Nov 28, 2017
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add default group name configuartion to CapOptions.
parent
e21cdd13
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
10 deletions
+25
-10
TopicAttribute.cs
src/DotNetCore.CAP/Abstractions/TopicAttribute.cs
+2
-1
CAP.Options.cs
src/DotNetCore.CAP/CAP.Options.cs
+8
-0
IConsumerServiceSelector.Default.cs
...tNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs
+15
-9
No files found.
src/DotNetCore.CAP/Abstractions/TopicAttribute.cs
View file @
019baee2
...
@@ -20,9 +20,10 @@ namespace DotNetCore.CAP.Abstractions
...
@@ -20,9 +20,10 @@ namespace DotNetCore.CAP.Abstractions
public
string
Name
{
get
;
}
public
string
Name
{
get
;
}
/// <summary>
/// <summary>
/// Default group name is CapOptions setting.(Assembly name)
/// kafka --> groups.id
/// kafka --> groups.id
/// rabbit MQ --> queue.name
/// rabbit MQ --> queue.name
/// </summary>
/// </summary>
public
string
Group
{
get
;
set
;
}
=
"cap.default.group"
;
public
string
Group
{
get
;
set
;
}
}
}
}
}
\ No newline at end of file
src/DotNetCore.CAP/CAP.Options.cs
View file @
019baee2
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Reflection
;
using
DotNetCore.CAP.Models
;
using
DotNetCore.CAP.Models
;
namespace
DotNetCore.CAP
namespace
DotNetCore.CAP
...
@@ -34,6 +35,7 @@ namespace DotNetCore.CAP
...
@@ -34,6 +35,7 @@ namespace DotNetCore.CAP
/// </summary>
/// </summary>
public
const
int
DefaultFailedRetryCount
=
100
;
public
const
int
DefaultFailedRetryCount
=
100
;
public
CapOptions
()
public
CapOptions
()
{
{
PollingDelay
=
DefaultPollingDelay
;
PollingDelay
=
DefaultPollingDelay
;
...
@@ -42,10 +44,16 @@ namespace DotNetCore.CAP
...
@@ -42,10 +44,16 @@ namespace DotNetCore.CAP
FailedRetryInterval
=
DefaultFailedMessageWaitingInterval
;
FailedRetryInterval
=
DefaultFailedMessageWaitingInterval
;
FailedRetryCount
=
DefaultFailedRetryCount
;
FailedRetryCount
=
DefaultFailedRetryCount
;
Extensions
=
new
List
<
ICapOptionsExtension
>();
Extensions
=
new
List
<
ICapOptionsExtension
>();
DefaultGroup
=
"cap.queue."
+
Assembly
.
GetEntryAssembly
().
GetName
().
Name
.
ToLower
();
}
}
internal
IList
<
ICapOptionsExtension
>
Extensions
{
get
;
}
internal
IList
<
ICapOptionsExtension
>
Extensions
{
get
;
}
/// <summary>
/// Subscriber default group name. kafka-->group name. rabbitmq --> queue name.
/// </summary>
public
string
DefaultGroup
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Producer job polling delay time.
/// Producer job polling delay time.
/// Default is 15 sec.
/// Default is 15 sec.
...
...
src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs
View file @
019baee2
...
@@ -10,23 +10,26 @@ namespace DotNetCore.CAP.Internal
...
@@ -10,23 +10,26 @@ namespace DotNetCore.CAP.Internal
{
{
/// <inheritdoc />
/// <inheritdoc />
/// <summary>
/// <summary>
/// A default <see cref="T:DotNetCore.CAP.Abstractions.IConsumerServiceSelector" /> implementation.
///
A default <see cref="T:DotNetCore.CAP.Abstractions.IConsumerServiceSelector" /> implementation.
/// </summary>
/// </summary>
internal
class
DefaultConsumerServiceSelector
:
IConsumerServiceSelector
internal
class
DefaultConsumerServiceSelector
:
IConsumerServiceSelector
{
{
private
readonly
CapOptions
_capOptions
;
private
readonly
IServiceProvider
_serviceProvider
;
private
readonly
IServiceProvider
_serviceProvider
;
/// <summary>
/// <summary>
/// Creates a new <see cref="DefaultConsumerServiceSelector" />.
///
Creates a new <see cref="DefaultConsumerServiceSelector" />.
/// </summary>
/// </summary>
public
DefaultConsumerServiceSelector
(
IServiceProvider
serviceProvider
)
public
DefaultConsumerServiceSelector
(
IServiceProvider
serviceProvider
,
CapOptions
capOptions
)
{
{
_serviceProvider
=
serviceProvider
;
_serviceProvider
=
serviceProvider
;
_capOptions
=
capOptions
;
}
}
/// <summary>
/// <summary>
/// Selects the best <see cref="ConsumerExecutorDescriptor" /> candidate from <paramref name="executeDescriptor" /> for the
/// Selects the best <see cref="ConsumerExecutorDescriptor" /> candidate from <paramref name="executeDescriptor" /> for
/// current message associated.
/// the
/// current message associated.
/// </summary>
/// </summary>
public
ConsumerExecutorDescriptor
SelectBestCandidate
(
string
key
,
public
ConsumerExecutorDescriptor
SelectBestCandidate
(
string
key
,
IReadOnlyList
<
ConsumerExecutorDescriptor
>
executeDescriptor
)
IReadOnlyList
<
ConsumerExecutorDescriptor
>
executeDescriptor
)
...
@@ -45,7 +48,7 @@ namespace DotNetCore.CAP.Internal
...
@@ -45,7 +48,7 @@ namespace DotNetCore.CAP.Internal
return
executorDescriptorList
;
return
executorDescriptorList
;
}
}
private
static
IEnumerable
<
ConsumerExecutorDescriptor
>
FindConsumersFromInterfaceTypes
(
private
IEnumerable
<
ConsumerExecutorDescriptor
>
FindConsumersFromInterfaceTypes
(
IServiceProvider
provider
)
IServiceProvider
provider
)
{
{
var
executorDescriptorList
=
new
List
<
ConsumerExecutorDescriptor
>();
var
executorDescriptorList
=
new
List
<
ConsumerExecutorDescriptor
>();
...
@@ -66,7 +69,7 @@ namespace DotNetCore.CAP.Internal
...
@@ -66,7 +69,7 @@ namespace DotNetCore.CAP.Internal
}
}
}
}
private
static
IEnumerable
<
ConsumerExecutorDescriptor
>
FindConsumersFromControllerTypes
()
private
IEnumerable
<
ConsumerExecutorDescriptor
>
FindConsumersFromControllerTypes
()
{
{
var
executorDescriptorList
=
new
List
<
ConsumerExecutorDescriptor
>();
var
executorDescriptorList
=
new
List
<
ConsumerExecutorDescriptor
>();
...
@@ -81,18 +84,21 @@ namespace DotNetCore.CAP.Internal
...
@@ -81,18 +84,21 @@ namespace DotNetCore.CAP.Internal
return
executorDescriptorList
;
return
executorDescriptorList
;
}
}
private
static
IEnumerable
<
ConsumerExecutorDescriptor
>
GetTopicAttributesDescription
(
TypeInfo
typeInfo
)
private
IEnumerable
<
ConsumerExecutorDescriptor
>
GetTopicAttributesDescription
(
TypeInfo
typeInfo
)
{
{
foreach
(
var
method
in
typeInfo
.
DeclaredMethods
)
foreach
(
var
method
in
typeInfo
.
DeclaredMethods
)
{
{
var
topicAttr
=
method
.
GetCustomAttributes
<
TopicAttribute
>(
true
);
var
topicAttr
=
method
.
GetCustomAttributes
<
TopicAttribute
>(
true
);
var
topicAttributes
=
topicAttr
as
IList
<
TopicAttribute
>
??
topicAttr
.
ToList
();
var
topicAttributes
=
topicAttr
as
IList
<
TopicAttribute
>
??
topicAttr
.
ToList
();
if
(!
topicAttributes
.
Any
())
continue
;
if
(!
topicAttributes
.
Any
())
continue
;
foreach
(
var
attr
in
topicAttributes
)
foreach
(
var
attr
in
topicAttributes
)
{
if
(
attr
.
Group
==
null
)
attr
.
Group
=
_capOptions
.
DefaultGroup
;
yield
return
InitDescriptor
(
attr
,
method
,
typeInfo
);
yield
return
InitDescriptor
(
attr
,
method
,
typeInfo
);
}
}
}
}
}
...
...
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