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
90f14f65
Commit
90f14f65
authored
Jul 17, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup code.
parent
22849556
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
49 additions
and
47 deletions
+49
-47
CAP.EFOptions.cs
src/DotNetCore.CAP.EntityFrameworkCore/CAP.EFOptions.cs
+1
-0
CAP.Options.Extensions.cs
...NetCore.CAP.EntityFrameworkCore/CAP.Options.Extensions.cs
+1
-0
CAP.SqlServerCapOptionsExtension.cs
...P.EntityFrameworkCore/CAP.SqlServerCapOptionsExtension.cs
+2
-1
CAP.SqlServerOptions.cs
...otNetCore.CAP.EntityFrameworkCore/CAP.SqlServerOptions.cs
+3
-2
SqlServerFetchedMessage.cs
...etCore.CAP.EntityFrameworkCore/SqlServerFetchedMessage.cs
+1
-0
SqlServerStorage.cs
src/DotNetCore.CAP.EntityFrameworkCore/SqlServerStorage.cs
+4
-4
SqlServerStorageConnection.cs
...ore.CAP.EntityFrameworkCore/SqlServerStorageConnection.cs
+1
-3
SqlServerStorageTransaction.cs
...re.CAP.EntityFrameworkCore/SqlServerStorageTransaction.cs
+5
-8
CAP.KafkaCapOptionsExtension.cs
src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs
+3
-2
CAP.KafkaOptions.cs
src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs
+1
-0
CAP.Options.Extensions.cs
src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs
+1
-0
CAP.Options.Extensions.cs
src/DotNetCore.CAP.RabbitMQ/CAP.Options.Extensions.cs
+1
-0
CAP.RabbiMQOptions.cs
src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs
+3
-2
CAP.RabbitMQCapOptionsExtension.cs
...otNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs
+2
-1
PublishQueueExecutor.cs
src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs
+12
-12
RabbitMQConsumerClient.cs
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs
+1
-1
IQueueExecutor.Publish.Base.cs
src/DotNetCore.CAP/IQueueExecutor.Publish.Base.cs
+1
-1
IQueueExecutor.Subscibe.cs
src/DotNetCore.CAP/IQueueExecutor.Subscibe.cs
+2
-1
QueueExecutorFactory.cs
src/DotNetCore.CAP/QueueExecutorFactory.cs
+4
-9
No files found.
src/DotNetCore.CAP.EntityFrameworkCore/CAP.EFOptions.cs
View file @
90f14f65
using
System
;
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
{
public
class
EFOptions
...
...
src/DotNetCore.CAP.EntityFrameworkCore/CAP.Options.Extensions.cs
View file @
90f14f65
...
...
@@ -2,6 +2,7 @@
using
DotNetCore.CAP
;
using
Microsoft.EntityFrameworkCore
;
// ReSharper disable once CheckNamespace
namespace
Microsoft.Extensions.DependencyInjection
{
public
static
class
CapOptionsExtensions
...
...
src/DotNetCore.CAP.EntityFrameworkCore/CAP.SqlServerCapOptionsExtension.cs
View file @
90f14f65
...
...
@@ -3,11 +3,12 @@ using DotNetCore.CAP.EntityFrameworkCore;
using
DotNetCore.CAP.Processor
;
using
Microsoft.Extensions.DependencyInjection
;
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
{
public
class
SqlServerCapOptionsExtension
:
ICapOptionsExtension
{
private
Action
<
SqlServerOptions
>
_configure
;
private
readonly
Action
<
SqlServerOptions
>
_configure
;
public
SqlServerCapOptionsExtension
(
Action
<
SqlServerOptions
>
configure
)
{
...
...
src/DotNetCore.CAP.EntityFrameworkCore/CAP.SqlServerOptions.cs
View file @
90f14f65
namespace
DotNetCore.CAP
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
{
public
class
SqlServerOptions
:
EFOptions
{
/// <summary>
/// Gets or sets the database's connection string that will be used to store database entities.
/// </summary>
public
string
ConnectionString
{
get
;
set
;
}
//= "Server=DESKTOP-M9R8T31;Initial Catalog=Test;User Id=sa;Password=P@ssw0rd;MultipleActiveResultSets=True";
public
string
ConnectionString
{
get
;
set
;
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.EntityFrameworkCore/SqlServerFetchedMessage.cs
View file @
90f14f65
...
...
@@ -66,6 +66,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
}
catch
{
// ignored
}
}
}
...
...
src/DotNetCore.CAP.EntityFrameworkCore/SqlServerStorage.cs
View file @
90f14f65
...
...
@@ -11,8 +11,8 @@ namespace DotNetCore.CAP.EntityFrameworkCore
{
public
class
SqlServerStorage
:
IStorage
{
private
IServiceProvider
_provider
;
private
ILogger
_logger
;
private
readonly
IServiceProvider
_provider
;
private
readonly
ILogger
_logger
;
public
SqlServerStorage
(
IServiceProvider
provider
,
...
...
@@ -43,7 +43,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
protected
virtual
string
CreateDbTablesScript
(
string
schema
)
{
var
batchS
QL
=
var
batchS
ql
=
$@"
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '
{
schema
}
')
BEGIN
...
...
@@ -96,7 +96,7 @@ CREATE TABLE [{schema}].[Published](
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO"
;
return
batchS
QL
;
return
batchS
ql
;
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.EntityFrameworkCore/SqlServerStorageConnection.cs
View file @
90f14f65
...
...
@@ -95,15 +95,13 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
private
async
Task
<
IFetchedMessage
>
FetchNextMessageCoreAsync
(
string
sql
,
object
args
=
null
)
{
FetchedMessage
fetched
=
null
;
using
(
var
connection
=
new
SqlConnection
(
_options
.
ConnectionString
))
{
using
(
var
transaction
=
connection
.
BeginTransaction
(
IsolationLevel
.
ReadCommitted
))
{
try
{
fetched
=
await
connection
.
QueryFirstOrDefaultAsync
<
FetchedMessage
>(
sql
,
args
,
transaction
);
var
fetched
=
await
connection
.
QueryFirstOrDefaultAsync
<
FetchedMessage
>(
sql
,
args
,
transaction
);
if
(
fetched
==
null
)
return
null
;
...
...
src/DotNetCore.CAP.EntityFrameworkCore/SqlServerStorageTransaction.cs
View file @
90f14f65
...
...
@@ -9,20 +9,17 @@ namespace DotNetCore.CAP.EntityFrameworkCore
{
public
class
SqlServerStorageTransaction
:
IStorageTransaction
,
IDisposable
{
private
readonly
SqlServerStorageConnection
_connection
;
private
readonly
SqlServerOptions
_options
;
private
readonly
string
_schema
;
private
IDbTransaction
_dbTransaction
;
private
IDbConnection
_dbConnection
;
private
readonly
IDbTransaction
_dbTransaction
;
private
readonly
IDbConnection
_dbConnection
;
public
SqlServerStorageTransaction
(
SqlServerStorageConnection
connection
)
{
_connection
=
connection
;
_options
=
_connection
.
Options
;
_schema
=
_options
.
Schema
;
var
options
=
connection
.
Options
;
_schema
=
options
.
Schema
;
_dbConnection
=
new
SqlConnection
(
_
options
.
ConnectionString
);
_dbConnection
=
new
SqlConnection
(
options
.
ConnectionString
);
_dbTransaction
=
_dbConnection
.
BeginTransaction
(
IsolationLevel
.
ReadCommitted
);
}
...
...
src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs
View file @
90f14f65
...
...
@@ -2,11 +2,12 @@
using
DotNetCore.CAP.Kafka
;
using
Microsoft.Extensions.DependencyInjection
;
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
{
public
class
KafkaCapOptionsExtension
:
ICapOptionsExtension
{
private
Action
<
KafkaOptions
>
_configure
;
private
readonly
Action
<
KafkaOptions
>
_configure
;
public
KafkaCapOptionsExtension
(
Action
<
KafkaOptions
>
configure
)
{
...
...
@@ -20,7 +21,7 @@ namespace DotNetCore.CAP
var
kafkaOptions
=
new
KafkaOptions
();
_configure
(
kafkaOptions
);
services
.
AddSingleton
(
kafkaOptions
);
services
.
AddSingleton
<
IConsumerClientFactory
,
KafkaConsumerClientFactory
>();
services
.
AddTransient
<
IQueueExecutor
,
PublishQueueExecutor
>();
}
...
...
src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs
View file @
90f14f65
...
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
System.Linq
;
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
{
/// <summary>
...
...
src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs
View file @
90f14f65
using
System
;
using
DotNetCore.CAP
;
// ReSharper disable once CheckNamespace
namespace
Microsoft.Extensions.DependencyInjection
{
public
static
class
CapOptionsExtensions
...
...
src/DotNetCore.CAP.RabbitMQ/CAP.Options.Extensions.cs
View file @
90f14f65
using
System
;
using
DotNetCore.CAP
;
// ReSharper disable once CheckNamespace
namespace
Microsoft.Extensions.DependencyInjection
{
public
static
class
CapOptionsExtensions
...
...
src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs
View file @
90f14f65
namespace
DotNetCore.CAP
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
{
public
class
RabbitMQOptions
{
...
...
@@ -34,7 +35,7 @@
public
string
HostName
{
get
;
set
;
}
=
"localhost"
;
/// <summary> The topic exchange type. </summary>
internal
string
EXCHANGE_TYPE
=
"topic"
;
internal
const
string
ExchangeType
=
"topic"
;
/// <summary>
/// Password to use when authenticating to the server.
...
...
src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs
View file @
90f14f65
...
...
@@ -2,11 +2,12 @@
using
DotNetCore.CAP.RabbitMQ
;
using
Microsoft.Extensions.DependencyInjection
;
// ReSharper disable once CheckNamespace
namespace
DotNetCore.CAP
{
public
class
RabbitMQCapOptionsExtension
:
ICapOptionsExtension
{
private
Action
<
RabbitMQOptions
>
_configure
;
private
readonly
Action
<
RabbitMQOptions
>
_configure
;
public
RabbitMQCapOptionsExtension
(
Action
<
RabbitMQOptions
>
configure
)
{
...
...
src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs
View file @
90f14f65
...
...
@@ -11,7 +11,7 @@ namespace DotNetCore.CAP.RabbitMQ
public
class
PublishQueueExecutor
:
BasePublishQueueExecutor
{
private
readonly
ILogger
_logger
;
private
readonly
RabbitMQOptions
_rabbitM
q
Options
;
private
readonly
RabbitMQOptions
_rabbitM
Q
Options
;
public
PublishQueueExecutor
(
IStateChanger
stateChanger
,
IOptions
<
RabbitMQOptions
>
options
,
...
...
@@ -19,21 +19,21 @@ namespace DotNetCore.CAP.RabbitMQ
:
base
(
stateChanger
,
logger
)
{
_logger
=
logger
;
_rabbitM
q
Options
=
options
.
Value
;
_rabbitM
Q
Options
=
options
.
Value
;
}
public
override
Task
<
OperateResult
>
PublishAsync
(
string
keyName
,
string
content
)
{
var
factory
=
new
ConnectionFactory
()
{
HostName
=
_rabbitM
q
Options
.
HostName
,
UserName
=
_rabbitM
q
Options
.
UserName
,
Port
=
_rabbitM
q
Options
.
Port
,
Password
=
_rabbitM
q
Options
.
Password
,
VirtualHost
=
_rabbitM
q
Options
.
VirtualHost
,
RequestedConnectionTimeout
=
_rabbitM
q
Options
.
RequestedConnectionTimeout
,
SocketReadTimeout
=
_rabbitM
q
Options
.
SocketReadTimeout
,
SocketWriteTimeout
=
_rabbitM
q
Options
.
SocketWriteTimeout
HostName
=
_rabbitM
Q
Options
.
HostName
,
UserName
=
_rabbitM
Q
Options
.
UserName
,
Port
=
_rabbitM
Q
Options
.
Port
,
Password
=
_rabbitM
Q
Options
.
Password
,
VirtualHost
=
_rabbitM
Q
Options
.
VirtualHost
,
RequestedConnectionTimeout
=
_rabbitM
Q
Options
.
RequestedConnectionTimeout
,
SocketReadTimeout
=
_rabbitM
Q
Options
.
SocketReadTimeout
,
SocketWriteTimeout
=
_rabbitM
Q
Options
.
SocketWriteTimeout
};
try
...
...
@@ -43,8 +43,8 @@ namespace DotNetCore.CAP.RabbitMQ
{
var
body
=
Encoding
.
UTF8
.
GetBytes
(
content
);
channel
.
ExchangeDeclare
(
_rabbitM
qOptions
.
TopicExchangeName
,
_rabbitMqOptions
.
EXCHANGE_TYPE
);
channel
.
BasicPublish
(
exchange
:
_rabbitM
q
Options
.
TopicExchangeName
,
channel
.
ExchangeDeclare
(
_rabbitM
QOptions
.
TopicExchangeName
,
RabbitMQOptions
.
ExchangeType
);
channel
.
BasicPublish
(
exchange
:
_rabbitM
Q
Options
.
TopicExchangeName
,
routingKey
:
keyName
,
basicProperties
:
null
,
body
:
body
);
...
...
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs
View file @
90f14f65
...
...
@@ -46,7 +46,7 @@ namespace DotNetCore.CAP.RabbitMQ
_connection
=
_connectionFactory
.
CreateConnection
();
_channel
=
_connection
.
CreateModel
();
_channel
.
ExchangeDeclare
(
exchange
:
_exchageName
,
type
:
_rabbitMQOptions
.
E
XCHANGE_TYPE
);
_channel
.
ExchangeDeclare
(
exchange
:
_exchageName
,
type
:
_rabbitMQOptions
.
E
xchangeType
);
_channel
.
QueueDeclare
(
_queueName
,
exclusive
:
false
);
}
...
...
src/DotNetCore.CAP/IQueueExecutor.Publish.Base.cs
View file @
90f14f65
...
...
@@ -13,7 +13,7 @@ namespace DotNetCore.CAP
private
readonly
IStateChanger
_stateChanger
;
private
readonly
ILogger
_logger
;
p
ublic
BasePublishQueueExecutor
(
IStateChanger
stateChanger
,
p
rotected
BasePublishQueueExecutor
(
IStateChanger
stateChanger
,
ILogger
<
BasePublishQueueExecutor
>
logger
)
{
_stateChanger
=
stateChanger
;
...
...
src/DotNetCore.CAP/IQueueExecutor.Subscibe.cs
View file @
90f14f65
...
...
@@ -116,7 +116,8 @@ namespace DotNetCore.CAP
}
catch
(
SubscriberNotFoundException
ex
)
{
throw
ex
;
_logger
.
LogError
(
"Can not be found subscribe method of name: "
+
receivedMessage
.
Name
);
return
OperateResult
.
Failed
(
ex
);
}
catch
(
Exception
ex
)
{
...
...
src/DotNetCore.CAP/QueueExecutorFactory.cs
View file @
90f14f65
...
...
@@ -17,16 +17,11 @@ namespace DotNetCore.CAP
public
IQueueExecutor
GetInstance
(
MessageType
messageType
)
{
var
_
queueExectors
=
_serviceProvider
.
GetServices
<
IQueueExecutor
>();
var
queueExectors
=
_serviceProvider
.
GetServices
<
IQueueExecutor
>();
if
(
messageType
==
MessageType
.
Publish
)
{
return
_queueExectors
.
FirstOrDefault
(
x
=>
typeof
(
BasePublishQueueExecutor
).
IsAssignableFrom
(
x
.
GetType
()));
}
else
{
return
_queueExectors
.
FirstOrDefault
(
x
=>
!
typeof
(
BasePublishQueueExecutor
).
IsAssignableFrom
(
x
.
GetType
()));
}
return
messageType
==
MessageType
.
Publish
?
queueExectors
.
FirstOrDefault
(
x
=>
x
is
BasePublishQueueExecutor
)
:
queueExectors
.
FirstOrDefault
(
x
=>
!(
x
is
BasePublishQueueExecutor
));
}
}
}
\ 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