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
98cd5861
Commit
98cd5861
authored
Jun 28, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor KafkaOptions
parent
f184550a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
35 deletions
+43
-35
ConsistencyMessageStore.cs
...etCore.CAP.EntityFrameworkCore/ConsistencyMessageStore.cs
+1
-1
CAP.BuilderExtensions.cs
src/DotNetCore.CAP.Kafka/CAP.BuilderExtensions.cs
+0
-1
CAP.KafkaOptions.cs
src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs
+34
-18
IProcessor.KafkaJobProcessor.cs
src/DotNetCore.CAP.Kafka/IProcessor.KafkaJobProcessor.cs
+1
-1
KafkaConsumerClient.cs
src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
+3
-5
CAP.RabbiMQOptions.cs
src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs
+2
-6
RabbitMQConsumerClientFactory.cs
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs
+1
-2
CAP.Options.cs
src/DotNetCore.CAP/CAP.Options.cs
+1
-1
No files found.
src/DotNetCore.CAP.EntityFrameworkCore/ConsistencyMessageStore.cs
View file @
98cd5861
...
...
@@ -35,7 +35,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
public
async
Task
<
OperateResult
>
StoreSentMessageAsync
(
CapSentMessage
message
)
{
if
(
message
==
null
)
throw
new
ArgumentNullException
(
nameof
(
message
));
Context
.
Add
(
message
);
await
Context
.
SaveChangesAsync
();
return
OperateResult
.
Success
;
...
...
src/DotNetCore.CAP.Kafka/CAP.BuilderExtensions.cs
View file @
98cd5861
...
...
@@ -18,7 +18,6 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>An <see cref="CapBuilder"/> for creating and configuring the CAP system.</returns>
public
static
CapBuilder
AddKafka
(
this
CapBuilder
builder
,
Action
<
KafkaOptions
>
setupAction
)
{
if
(
setupAction
==
null
)
throw
new
ArgumentNullException
(
nameof
(
setupAction
));
builder
.
Services
.
Configure
(
setupAction
);
...
...
src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs
View file @
98cd5861
using
System
;
using
System.Collections.Generic
;
using
System.
Text
;
using
System.
Linq
;
namespace
DotNetCore.CAP.Kafka
{
/// <summary>
/// Provides programmatic configuration for the CAP kafka project.
/// </summary>
public
class
KafkaOptions
{
/// <summary>
/// Gets the Kafka broker id.
/// </summary>
public
int
BrokerId
{
get
;
}
public
KafkaOptions
()
{
MainConfig
=
new
Dictionary
<
string
,
object
>();
}
/// <summary>
/// Gets the Kafka broker hostname.
/// librdkafka configuration parameters (refer to https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md).
/// <para>
/// Topic configuration parameters are specified via the "default.topic.config" sub-dictionary config parameter.
/// </para>
/// </summary>
public
string
Host
{
g
et
;
}
public
IDictionary
<
string
,
object
>
MainConfig
{
get
;
private
s
et
;
}
/// <summary>
/// Gets the Kafka broker port.
/// The `bootstrap.servers` item config of `MainConfig`.
/// <para>
/// Initial list of brokers as a CSV list of broker host or host:port.
/// </para>
/// </summary>
public
int
Port
{
g
et
;
}
public
string
Servers
{
get
;
s
et
;
}
/// <summary>
/// Returns a JSON representation of the BrokerMetadata object.
/// </summary>
/// <returns>
/// A JSON representation of the BrokerMetadata object.
/// </returns>
public
override
string
ToString
()
=>
$"
{{
\
"BrokerId\": {BrokerId}, \"Host\": \"{Host}\", \"Port\": {Port} }}"
;
internal
IEnumerable
<
KeyValuePair
<
string
,
object
>>
AsRdkafkaConfig
()
{
if
(!
MainConfig
.
ContainsKey
(
"bootstrap.servers"
))
{
if
(
string
.
IsNullOrEmpty
(
Servers
))
{
throw
new
ArgumentNullException
(
nameof
(
Servers
));
}
else
{
MainConfig
.
Add
(
"bootstrap.servers"
,
Servers
);
}
}
return
MainConfig
.
AsEnumerable
();
}
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.Kafka/IProcessor.KafkaJobProcessor.cs
View file @
98cd5861
...
...
@@ -123,7 +123,7 @@ namespace DotNetCore.CAP.Kafka
{
try
{
var
config
=
new
Dictionary
<
string
,
object
>
{
{
"bootstrap.servers"
,
_kafkaOptions
.
Host
}
}
;
var
config
=
_kafkaOptions
.
AsRdkafkaConfig
()
;
using
(
var
producer
=
new
Producer
<
Null
,
string
>(
config
,
null
,
new
StringSerializer
(
Encoding
.
UTF8
)))
{
var
message
=
producer
.
ProduceAsync
(
topic
,
null
,
content
).
Result
;
...
...
src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
View file @
98cd5861
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
Confluent.Kafka
;
using
Confluent.Kafka.Serialization
;
...
...
@@ -56,12 +55,11 @@ namespace DotNetCore.CAP.Kafka
private
void
InitKafkaClient
()
{
var
config
=
new
Dictionary
<
string
,
object
>{
{
"group.id"
,
_groupId
},
{
"bootstrap.servers"
,
_kafkaOptions
.
Host
}
};
_kafkaOptions
.
MainConfig
.
Add
(
"group.id"
,
_groupId
);
var
config
=
_kafkaOptions
.
AsRdkafkaConfig
();
_consumerClient
=
new
Consumer
<
Null
,
string
>(
config
,
null
,
StringDeserializer
);
_consumerClient
.
OnMessage
+=
ConsumerClient_OnMessage
;
}
...
...
src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs
View file @
98cd5861
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
DotNetCore.CAP.RabbitMQ
namespace
DotNetCore.CAP.RabbitMQ
{
public
class
RabbitMQOptions
{
...
...
@@ -68,4 +64,4 @@ namespace DotNetCore.CAP.RabbitMQ
/// </summary>
public
int
Port
{
get
;
set
;
}
=
-
1
;
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs
View file @
98cd5861
using
DotNetCore.CAP.Infrastructure
;
using
Microsoft.Extensions.Options
;
using
Microsoft.Extensions.Options
;
namespace
DotNetCore.CAP.RabbitMQ
{
...
...
src/DotNetCore.CAP/CAP.Options.cs
View file @
98cd5861
...
...
@@ -7,7 +7,7 @@ namespace DotNetCore.CAP.Infrastructure
/// </summary>
public
class
CapOptions
{
/// <summary>
/// <summary>
/// Corn expression for configuring retry cron job. Default is 1 min.
/// </summary>
public
string
CronExp
{
get
;
set
;
}
=
Cron
.
Minutely
();
...
...
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