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
bc36b3d4
Commit
bc36b3d4
authored
May 31, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
ad7abc50
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
23 deletions
+29
-23
ConsumerExecutorDescriptor.cs
...ap.Consistency/Abstractions/ConsumerExecutorDescriptor.cs
+1
-3
TopicAttribute.cs
src/Cap.Consistency/Abstractions/TopicAttribute.cs
+2
-0
ConsistencyBuilder.cs
src/Cap.Consistency/Builder/ConsistencyBuilder.cs
+3
-8
ConsumerHandler.cs
src/Cap.Consistency/Consumer/ConsumerHandler.cs
+11
-12
ConsistencyOptions.cs
src/Cap.Consistency/Infrastructure/ConsistencyOptions.cs
+12
-0
No files found.
src/Cap.Consistency/Abstractions/ConsumerExecutorDescriptor.cs
View file @
bc36b3d4
...
...
@@ -11,8 +11,6 @@ namespace Cap.Consistency.Abstractions
public
TypeInfo
ImplTypeInfo
{
get
;
set
;
}
public
TopicInfo
Topic
{
get
;
set
;
}
public
string
GroupId
{
get
;
set
;
}
public
TopicAttribute
Attribute
{
get
;
set
;
}
}
}
src/Cap.Consistency/Abstractions/TopicAttribute.cs
View file @
bc36b3d4
...
...
@@ -18,6 +18,8 @@ namespace Cap.Consistency.Abstractions
get
{
return
_name
;
}
}
public
string
GroupOrExchange
{
get
;
set
;
}
public
bool
IsOneWay
{
get
;
set
;
}
}
}
src/Cap.Consistency/Builder/ConsistencyBuilder.cs
View file @
bc36b3d4
...
...
@@ -27,8 +27,6 @@ namespace Cap.Consistency
Services
=
service
;
AddConsumerServices
();
AddKafkaServices
();
}
/// <summary>
...
...
@@ -70,13 +68,10 @@ namespace Cap.Consistency
Services
.
AddSingleton
<
IConsumerInvokerFactory
,
ConsumerInvokerFactory
>();
Services
.
AddSingleton
<
MethodMatcherCache
>();
return
this
;
}
public
virtual
ConsistencyBuilder
AddKafkaServices
()
{
Services
.
AddSingleton
(
typeof
(
ITopicRoute
),
typeof
(
ConsumerHandler
<>).
MakeGenericType
(
MessageType
));
return
AddScoped
(
typeof
(
ITopicRoute
),
typeof
(
ConsumerHandler
<>).
MakeGenericType
(
MessageType
))
;
}
return
this
;
}
/// <summary>
...
...
src/Cap.Consistency/Consumer/ConsumerHandler.cs
View file @
bc36b3d4
...
...
@@ -5,10 +5,9 @@ using System.Threading.Tasks;
using
Cap.Consistency.Abstractions
;
using
Cap.Consistency.Infrastructure
;
using
Cap.Consistency.Routing
;
using
Microsoft.AspNetCore.Builder
;
using
Cap.Consistency.Internal
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
Cap.Consistency.Internal
;
namespace
Cap.Consistency.Consumer
{
...
...
@@ -59,18 +58,20 @@ namespace Cap.Consistency.Consumer
var
matchs
=
_selector
.
GetCandidatesMethods
(
context
);
var
groupingMatchs
=
matchs
.
GroupBy
(
x
=>
x
.
Value
.
GroupId
);
var
groupingMatchs
=
matchs
.
GroupBy
(
x
=>
x
.
Value
.
Attribute
.
GroupOrExchange
);
foreach
(
var
matchGroup
in
groupingMatchs
)
{
using
(
var
client
=
_consumerClientFactory
.
Create
(
matchGroup
.
Key
,
_options
.
BrokerUrlList
))
{
client
.
MessageReceieved
+=
OnMessageReceieved
;
Task
.
Factory
.
StartNew
(()
=>
{
using
(
var
client
=
_consumerClientFactory
.
Create
(
matchGroup
.
Key
,
_options
.
BrokerUrlList
))
{
client
.
MessageReceieved
+=
OnMessageReceieved
;
foreach
(
var
item
in
matchGroup
)
{
client
.
Subscribe
(
item
.
Key
,
item
.
Value
.
Topic
.
Partition
);
}
foreach
(
var
item
in
matchGroup
)
{
client
.
Subscribe
(
item
.
Key
);
}
client
.
Listening
(
TimeSpan
.
Zero
);
}
client
.
Listening
(
TimeSpan
.
FromSeconds
(
1
));
}
},
TaskCreationOptions
.
LongRunning
);
}
return
Task
.
CompletedTask
;
}
...
...
@@ -100,8 +101,6 @@ namespace Cap.Consistency.Consumer
catch
(
Exception
ex
)
{
_logger
.
LogError
(
"exception raised when excute method : "
+
ex
.
Message
);
throw
ex
;
}
}
}
...
...
src/Cap.Consistency/Infrastructure/ConsistencyOptions.cs
0 → 100644
View file @
bc36b3d4
using
Cap.Consistency
;
namespace
Cap.Consistency.Infrastructure
{
/// <summary>
/// Represents all the options you can use to configure the system.
/// </summary>
public
class
ConsistencyOptions
{
public
string
BrokerUrlList
{
get
;
set
;
}
=
"localhost:9092"
;
}
}
\ No newline at end of file
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