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
c9cc5591
Commit
c9cc5591
authored
Jul 28, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor and add some comment.
parent
75de50d4
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
41 additions
and
32 deletions
+41
-32
CAP.KafkaCapOptionsExtension.cs
src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs
+2
-4
CAP.Options.Extensions.cs
src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs
+9
-0
CAP.SubscribeAttribute.cs
src/DotNetCore.CAP.Kafka/CAP.SubscribeAttribute.cs
+3
-0
KafkaConsumerClient.cs
src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
+1
-1
KafkaConsumerClientFactory.cs
src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs
+3
-3
PublishQueueExecutor.cs
src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs
+3
-4
CAP.MySqlCapOptionsExtension.cs
src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs
+1
-1
FetchedMessage.cs
src/DotNetCore.CAP.MySql/FetchedMessage.cs
+1
-1
IAdditionalProcessor.Default.cs
src/DotNetCore.CAP.MySql/IAdditionalProcessor.Default.cs
+1
-1
CAP.Options.Extensions.cs
src/DotNetCore.CAP.RabbitMQ/CAP.Options.Extensions.cs
+1
-1
CAP.RabbitMQCapOptionsExtension.cs
...otNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs
+4
-7
CAP.SubscribeAttribute.cs
src/DotNetCore.CAP.RabbitMQ/CAP.SubscribeAttribute.cs
+3
-0
PublishQueueExecutor.cs
src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs
+3
-3
RabbitMQConsumerClient.cs
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs
+1
-1
RabbitMQConsumerClientFactory.cs
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs
+3
-3
CAP.SqlServerCapOptionsExtension.cs
...NetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs
+1
-1
FetchedMessage.cs
src/DotNetCore.CAP.SqlServer/FetchedMessage.cs
+1
-1
No files found.
src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs
View file @
c9cc5591
...
@@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
...
@@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
namespace
DotNetCore.CAP
{
{
public
class
KafkaCapOptionsExtension
:
ICapOptionsExtension
internal
sealed
class
KafkaCapOptionsExtension
:
ICapOptionsExtension
{
{
private
readonly
Action
<
KafkaOptions
>
_configure
;
private
readonly
Action
<
KafkaOptions
>
_configure
;
...
@@ -16,10 +16,8 @@ namespace DotNetCore.CAP
...
@@ -16,10 +16,8 @@ namespace DotNetCore.CAP
public
void
AddServices
(
IServiceCollection
services
)
public
void
AddServices
(
IServiceCollection
services
)
{
{
services
.
Configure
(
_configure
);
var
kafkaOptions
=
new
KafkaOptions
();
var
kafkaOptions
=
new
KafkaOptions
();
_configure
(
kafkaOptions
);
_configure
?.
Invoke
(
kafkaOptions
);
services
.
AddSingleton
(
kafkaOptions
);
services
.
AddSingleton
(
kafkaOptions
);
services
.
AddSingleton
<
IConsumerClientFactory
,
KafkaConsumerClientFactory
>();
services
.
AddSingleton
<
IConsumerClientFactory
,
KafkaConsumerClientFactory
>();
...
...
src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs
View file @
c9cc5591
...
@@ -6,6 +6,10 @@ namespace Microsoft.Extensions.DependencyInjection
...
@@ -6,6 +6,10 @@ namespace Microsoft.Extensions.DependencyInjection
{
{
public
static
class
CapOptionsExtensions
public
static
class
CapOptionsExtensions
{
{
/// <summary>
/// Configuration to use kafka in CAP.
/// </summary>
/// <param name="bootstrapServers">Kafka bootstrap server urls.</param>
public
static
CapOptions
UseKafka
(
this
CapOptions
options
,
string
bootstrapServers
)
public
static
CapOptions
UseKafka
(
this
CapOptions
options
,
string
bootstrapServers
)
{
{
return
options
.
UseKafka
(
opt
=>
return
options
.
UseKafka
(
opt
=>
...
@@ -14,6 +18,11 @@ namespace Microsoft.Extensions.DependencyInjection
...
@@ -14,6 +18,11 @@ namespace Microsoft.Extensions.DependencyInjection
});
});
}
}
/// <summary>
/// Configuration to use kafka in CAP.
/// </summary>
/// <param name="configure">Provides programmatic configuration for the kafka .</param>
/// <returns></returns>
public
static
CapOptions
UseKafka
(
this
CapOptions
options
,
Action
<
KafkaOptions
>
configure
)
public
static
CapOptions
UseKafka
(
this
CapOptions
options
,
Action
<
KafkaOptions
>
configure
)
{
{
if
(
configure
==
null
)
throw
new
ArgumentNullException
(
nameof
(
configure
));
if
(
configure
==
null
)
throw
new
ArgumentNullException
(
nameof
(
configure
));
...
...
src/DotNetCore.CAP.Kafka/CAP.SubscribeAttribute.cs
View file @
c9cc5591
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
namespace
DotNetCore.CAP
{
{
/// <summary>
/// An attribute for subscribe Kafka messages.
/// </summary>
public
class
CapSubscribeAttribute
:
TopicAttribute
public
class
CapSubscribeAttribute
:
TopicAttribute
{
{
public
CapSubscribeAttribute
(
string
name
)
public
CapSubscribeAttribute
(
string
name
)
...
...
src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
View file @
c9cc5591
...
@@ -6,7 +6,7 @@ using Confluent.Kafka.Serialization;
...
@@ -6,7 +6,7 @@ using Confluent.Kafka.Serialization;
namespace
DotNetCore.CAP.Kafka
namespace
DotNetCore.CAP.Kafka
{
{
public
class
KafkaConsumerClient
:
IConsumerClient
internal
sealed
class
KafkaConsumerClient
:
IConsumerClient
{
{
private
readonly
string
_groupId
;
private
readonly
string
_groupId
;
private
readonly
KafkaOptions
_kafkaOptions
;
private
readonly
KafkaOptions
_kafkaOptions
;
...
...
src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs
View file @
c9cc5591
...
@@ -3,13 +3,13 @@ using Microsoft.Extensions.Options;
...
@@ -3,13 +3,13 @@ using Microsoft.Extensions.Options;
namespace
DotNetCore.CAP.Kafka
namespace
DotNetCore.CAP.Kafka
{
{
public
class
KafkaConsumerClientFactory
:
IConsumerClientFactory
internal
sealed
class
KafkaConsumerClientFactory
:
IConsumerClientFactory
{
{
private
readonly
KafkaOptions
_kafkaOptions
;
private
readonly
KafkaOptions
_kafkaOptions
;
public
KafkaConsumerClientFactory
(
IOptions
<
KafkaOptions
>
kafkaOptions
)
public
KafkaConsumerClientFactory
(
KafkaOptions
kafkaOptions
)
{
{
_kafkaOptions
=
kafkaOptions
?.
Value
??
throw
new
ArgumentNullException
(
nameof
(
kafkaOptions
))
;
_kafkaOptions
=
kafkaOptions
;
}
}
public
IConsumerClient
Create
(
string
groupId
)
public
IConsumerClient
Create
(
string
groupId
)
...
...
src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs
View file @
c9cc5591
...
@@ -4,22 +4,21 @@ using System.Threading.Tasks;
...
@@ -4,22 +4,21 @@ using System.Threading.Tasks;
using
Confluent.Kafka
;
using
Confluent.Kafka
;
using
DotNetCore.CAP.Processor.States
;
using
DotNetCore.CAP.Processor.States
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
namespace
DotNetCore.CAP.Kafka
namespace
DotNetCore.CAP.Kafka
{
{
public
class
PublishQueueExecutor
:
BasePublishQueueExecutor
internal
class
PublishQueueExecutor
:
BasePublishQueueExecutor
{
{
private
readonly
ILogger
_logger
;
private
readonly
ILogger
_logger
;
private
readonly
KafkaOptions
_kafkaOptions
;
private
readonly
KafkaOptions
_kafkaOptions
;
public
PublishQueueExecutor
(
IStateChanger
stateChanger
,
public
PublishQueueExecutor
(
IStateChanger
stateChanger
,
IOptions
<
KafkaOptions
>
options
,
KafkaOptions
options
,
ILogger
<
PublishQueueExecutor
>
logger
)
ILogger
<
PublishQueueExecutor
>
logger
)
:
base
(
stateChanger
,
logger
)
:
base
(
stateChanger
,
logger
)
{
{
_logger
=
logger
;
_logger
=
logger
;
_kafkaOptions
=
options
.
Value
;
_kafkaOptions
=
options
;
}
}
public
override
Task
<
OperateResult
>
PublishAsync
(
string
keyName
,
string
content
)
public
override
Task
<
OperateResult
>
PublishAsync
(
string
keyName
,
string
content
)
...
...
src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs
View file @
c9cc5591
...
@@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection;
...
@@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection;
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
namespace
DotNetCore.CAP
{
{
public
class
MySqlCapOptionsExtension
:
ICapOptionsExtension
internal
class
MySqlCapOptionsExtension
:
ICapOptionsExtension
{
{
private
readonly
Action
<
MySqlOptions
>
_configure
;
private
readonly
Action
<
MySqlOptions
>
_configure
;
...
...
src/DotNetCore.CAP.MySql/FetchedMessage.cs
View file @
c9cc5591
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
namespace
DotNetCore.CAP.MySql
namespace
DotNetCore.CAP.MySql
{
{
public
class
FetchedMessage
internal
class
FetchedMessage
{
{
public
int
MessageId
{
get
;
set
;
}
public
int
MessageId
{
get
;
set
;
}
...
...
src/DotNetCore.CAP.MySql/IAdditionalProcessor.Default.cs
View file @
c9cc5591
...
@@ -7,7 +7,7 @@ using MySql.Data.MySqlClient;
...
@@ -7,7 +7,7 @@ using MySql.Data.MySqlClient;
namespace
DotNetCore.CAP.MySql
namespace
DotNetCore.CAP.MySql
{
{
public
class
DefaultAdditionalProcessor
:
IAdditionalProcessor
internal
class
DefaultAdditionalProcessor
:
IAdditionalProcessor
{
{
private
readonly
IServiceProvider
_provider
;
private
readonly
IServiceProvider
_provider
;
private
readonly
ILogger
_logger
;
private
readonly
ILogger
_logger
;
...
...
src/DotNetCore.CAP.RabbitMQ/CAP.Options.Extensions.cs
View file @
c9cc5591
...
@@ -4,7 +4,7 @@ using DotNetCore.CAP;
...
@@ -4,7 +4,7 @@ using DotNetCore.CAP;
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace
Microsoft.Extensions.DependencyInjection
namespace
Microsoft.Extensions.DependencyInjection
{
{
public
static
class
CapOptionsExtensions
internal
static
class
CapOptionsExtensions
{
{
public
static
CapOptions
UseRabbitMQ
(
this
CapOptions
options
,
string
hostName
)
public
static
CapOptions
UseRabbitMQ
(
this
CapOptions
options
,
string
hostName
)
{
{
...
...
src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs
View file @
c9cc5591
...
@@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
...
@@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
namespace
DotNetCore.CAP
{
{
public
class
RabbitMQCapOptionsExtension
:
ICapOptionsExtension
internal
sealed
class
RabbitMQCapOptionsExtension
:
ICapOptionsExtension
{
{
private
readonly
Action
<
RabbitMQOptions
>
_configure
;
private
readonly
Action
<
RabbitMQOptions
>
_configure
;
...
@@ -16,12 +16,9 @@ namespace DotNetCore.CAP
...
@@ -16,12 +16,9 @@ namespace DotNetCore.CAP
public
void
AddServices
(
IServiceCollection
services
)
public
void
AddServices
(
IServiceCollection
services
)
{
{
services
.
Configure
(
_configure
);
var
options
=
new
RabbitMQOptions
();
_configure
?.
Invoke
(
options
);
var
rabbitMQOptions
=
new
RabbitMQOptions
();
services
.
AddSingleton
(
options
);
_configure
(
rabbitMQOptions
);
services
.
AddSingleton
(
rabbitMQOptions
);
services
.
AddSingleton
<
IConsumerClientFactory
,
RabbitMQConsumerClientFactory
>();
services
.
AddSingleton
<
IConsumerClientFactory
,
RabbitMQConsumerClientFactory
>();
services
.
AddTransient
<
IQueueExecutor
,
PublishQueueExecutor
>();
services
.
AddTransient
<
IQueueExecutor
,
PublishQueueExecutor
>();
...
...
src/DotNetCore.CAP.RabbitMQ/CAP.SubscribeAttribute.cs
View file @
c9cc5591
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
namespace
DotNetCore.CAP
{
{
/// <summary>
/// An attribute for subscribe RabbitMQ messages.
/// </summary>
public
class
CapSubscribeAttribute
:
TopicAttribute
public
class
CapSubscribeAttribute
:
TopicAttribute
{
{
public
CapSubscribeAttribute
(
string
name
)
:
base
(
name
)
public
CapSubscribeAttribute
(
string
name
)
:
base
(
name
)
...
...
src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs
View file @
c9cc5591
...
@@ -8,18 +8,18 @@ using RabbitMQ.Client;
...
@@ -8,18 +8,18 @@ using RabbitMQ.Client;
namespace
DotNetCore.CAP.RabbitMQ
namespace
DotNetCore.CAP.RabbitMQ
{
{
public
class
PublishQueueExecutor
:
BasePublishQueueExecutor
internal
sealed
class
PublishQueueExecutor
:
BasePublishQueueExecutor
{
{
private
readonly
ILogger
_logger
;
private
readonly
ILogger
_logger
;
private
readonly
RabbitMQOptions
_rabbitMQOptions
;
private
readonly
RabbitMQOptions
_rabbitMQOptions
;
public
PublishQueueExecutor
(
IStateChanger
stateChanger
,
public
PublishQueueExecutor
(
IStateChanger
stateChanger
,
IOptions
<
RabbitMQOptions
>
options
,
RabbitMQOptions
options
,
ILogger
<
PublishQueueExecutor
>
logger
)
ILogger
<
PublishQueueExecutor
>
logger
)
:
base
(
stateChanger
,
logger
)
:
base
(
stateChanger
,
logger
)
{
{
_logger
=
logger
;
_logger
=
logger
;
_rabbitMQOptions
=
options
.
Value
;
_rabbitMQOptions
=
options
;
}
}
public
override
Task
<
OperateResult
>
PublishAsync
(
string
keyName
,
string
content
)
public
override
Task
<
OperateResult
>
PublishAsync
(
string
keyName
,
string
content
)
...
...
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs
View file @
c9cc5591
...
@@ -7,7 +7,7 @@ using RabbitMQ.Client.Events;
...
@@ -7,7 +7,7 @@ using RabbitMQ.Client.Events;
namespace
DotNetCore.CAP.RabbitMQ
namespace
DotNetCore.CAP.RabbitMQ
{
{
public
class
RabbitMQConsumerClient
:
IConsumerClient
internal
sealed
class
RabbitMQConsumerClient
:
IConsumerClient
{
{
private
readonly
string
_exchageName
;
private
readonly
string
_exchageName
;
private
readonly
string
_queueName
;
private
readonly
string
_queueName
;
...
...
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs
View file @
c9cc5591
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
namespace
DotNetCore.CAP.RabbitMQ
namespace
DotNetCore.CAP.RabbitMQ
{
{
public
class
RabbitMQConsumerClientFactory
:
IConsumerClientFactory
internal
sealed
class
RabbitMQConsumerClientFactory
:
IConsumerClientFactory
{
{
private
readonly
RabbitMQOptions
_rabbitMQOptions
;
private
readonly
RabbitMQOptions
_rabbitMQOptions
;
public
RabbitMQConsumerClientFactory
(
IOptions
<
RabbitMQOptions
>
rabbitMQOptions
)
public
RabbitMQConsumerClientFactory
(
RabbitMQOptions
rabbitMQOptions
)
{
{
_rabbitMQOptions
=
rabbitMQOptions
.
Value
;
_rabbitMQOptions
=
rabbitMQOptions
;
}
}
public
IConsumerClient
Create
(
string
groupId
)
public
IConsumerClient
Create
(
string
groupId
)
...
...
src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs
View file @
c9cc5591
...
@@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection;
...
@@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection;
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
namespace
DotNetCore.CAP
{
{
public
class
SqlServerCapOptionsExtension
:
ICapOptionsExtension
internal
class
SqlServerCapOptionsExtension
:
ICapOptionsExtension
{
{
private
readonly
Action
<
SqlServerOptions
>
_configure
;
private
readonly
Action
<
SqlServerOptions
>
_configure
;
...
...
src/DotNetCore.CAP.SqlServer/FetchedMessage.cs
View file @
c9cc5591
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
namespace
DotNetCore.CAP.SqlServer
namespace
DotNetCore.CAP.SqlServer
{
{
public
class
FetchedMessage
internal
class
FetchedMessage
{
{
public
int
MessageId
{
get
;
set
;
}
public
int
MessageId
{
get
;
set
;
}
...
...
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