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
3ebc726c
Commit
3ebc726c
authored
Jun 14, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clear up code.
parent
5568daa8
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
24 additions
and
66 deletions
+24
-66
ConsistencyEntityFrameworkBuilderExtensions.cs
...meworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs
+0
-1
ConsistencyMessageStore.cs
...onsistency.EntityFrameworkCore/ConsistencyMessageStore.cs
+0
-1
KafkaConsumerClient.cs
src/Cap.Consistency.Kafka/KafkaConsumerClient.cs
+2
-6
KafkaConsumerClientFactory.cs
src/Cap.Consistency.Kafka/KafkaConsumerClientFactory.cs
+2
-5
KafkaProducerClient.cs
src/Cap.Consistency.Kafka/KafkaProducerClient.cs
+1
-3
KafkaTopicAttribute.cs
src/Cap.Consistency.Kafka/KafkaTopicAttribute.cs
+2
-5
ConsistencyBuilderExtensions.cs
...sions.DependencyInjection/ConsistencyBuilderExtensions.cs
+2
-8
RabbitMQConsumerClient.cs
src/Cap.Consistency.RabbitMQ/RabbitMQConsumerClient.cs
+2
-4
RabbitMQConsumerClientFactory.cs
...Cap.Consistency.RabbitMQ/RabbitMQConsumerClientFactory.cs
+2
-5
RabbitMQProducerClient.cs
src/Cap.Consistency.RabbitMQ/RabbitMQProducerClient.cs
+2
-6
IConsumerHandler.cs
src/Cap.Consistency/Consumer/IConsumerHandler.cs
+3
-9
DefaultPocoTest.cs
...p.Consistency.EntityFrameworkCore.Test/DefaultPocoTest.cs
+2
-6
MessageStoreTest.cs
....Consistency.EntityFrameworkCore.Test/MessageStoreTest.cs
+3
-4
MessageStoreWithGenericsTest.cs
....EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs
+0
-1
ConsistencyMessageManagerTest.cs
test/Cap.Consistency.Test/ConsistencyMessageManagerTest.cs
+1
-2
No files found.
src/Cap.Consistency.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs
View file @
3ebc726c
...
@@ -17,7 +17,6 @@ namespace Microsoft.Extensions.DependencyInjection
...
@@ -17,7 +17,6 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="ConsistencyBuilder"/> instance this method extends.</returns>
/// <returns>The <see cref="ConsistencyBuilder"/> instance this method extends.</returns>
public
static
ConsistencyBuilder
AddEntityFrameworkStores
<
TContext
>(
this
ConsistencyBuilder
builder
)
public
static
ConsistencyBuilder
AddEntityFrameworkStores
<
TContext
>(
this
ConsistencyBuilder
builder
)
where
TContext
:
DbContext
{
where
TContext
:
DbContext
{
builder
.
Services
.
AddScoped
<
IConsistencyMessageStore
,
ConsistencyMessageStore
<
TContext
>>();
builder
.
Services
.
AddScoped
<
IConsistencyMessageStore
,
ConsistencyMessageStore
<
TContext
>>();
return
builder
;
return
builder
;
...
...
src/Cap.Consistency.EntityFrameworkCore/ConsistencyMessageStore.cs
View file @
3ebc726c
using
System
;
using
System
;
using
System.ComponentModel
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Cap.Consistency.Infrastructure
;
using
Cap.Consistency.Infrastructure
;
...
...
src/Cap.Consistency.Kafka/KafkaConsumerClient.cs
View file @
3ebc726c
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
Cap.Consistency.Consumer
;
using
Cap.Consistency.Consumer
;
using
Cap.Consistency.Infrastructure
;
using
Cap.Consistency.Infrastructure
;
...
@@ -11,7 +10,6 @@ namespace Cap.Consistency.Kafka
...
@@ -11,7 +10,6 @@ namespace Cap.Consistency.Kafka
{
{
public
class
KafkaConsumerClient
:
IConsumerClient
public
class
KafkaConsumerClient
:
IConsumerClient
{
{
private
readonly
string
_groupId
;
private
readonly
string
_groupId
;
private
readonly
string
_bootstrapServers
;
private
readonly
string
_bootstrapServers
;
...
@@ -33,7 +31,6 @@ namespace Cap.Consistency.Kafka
...
@@ -33,7 +31,6 @@ namespace Cap.Consistency.Kafka
}
}
public
void
Subscribe
(
string
topicName
,
int
partition
)
{
public
void
Subscribe
(
string
topicName
,
int
partition
)
{
if
(
_consumerClient
==
null
)
{
if
(
_consumerClient
==
null
)
{
InitKafkaClient
();
InitKafkaClient
();
}
}
...
@@ -72,7 +69,6 @@ namespace Cap.Consistency.Kafka
...
@@ -72,7 +69,6 @@ namespace Cap.Consistency.Kafka
MessageReceieved
?.
Invoke
(
sender
,
message
);
MessageReceieved
?.
Invoke
(
sender
,
message
);
}
}
#
endregion
#
endregion
private
methods
}
}
}
}
\ No newline at end of file
src/Cap.Consistency.Kafka/KafkaConsumerClientFactory.cs
View file @
3ebc726c
using
System
;
using
Cap.Consistency.Consumer
;
using
System.Collections.Generic
;
using
System.Text
;
using
Cap.Consistency.Consumer
;
namespace
Cap.Consistency.Kafka
namespace
Cap.Consistency.Kafka
{
{
...
...
src/Cap.Consistency.Kafka/KafkaProducerClient.cs
View file @
3ebc726c
...
@@ -14,7 +14,6 @@ namespace Cap.Consistency.Kafka
...
@@ -14,7 +14,6 @@ namespace Cap.Consistency.Kafka
{
{
public
class
KafkaProducerClient
:
IProducerClient
public
class
KafkaProducerClient
:
IProducerClient
{
{
private
readonly
ConsistencyOptions
_options
;
private
readonly
ConsistencyOptions
_options
;
private
readonly
ILogger
_logger
;
private
readonly
ILogger
_logger
;
...
@@ -23,7 +22,6 @@ namespace Cap.Consistency.Kafka
...
@@ -23,7 +22,6 @@ namespace Cap.Consistency.Kafka
_logger
=
loggerFactory
.
CreateLogger
(
nameof
(
KafkaProducerClient
));
_logger
=
loggerFactory
.
CreateLogger
(
nameof
(
KafkaProducerClient
));
}
}
public
Task
SendAsync
(
string
topic
,
string
content
)
{
public
Task
SendAsync
(
string
topic
,
string
content
)
{
var
config
=
new
Dictionary
<
string
,
object
>
{
{
"bootstrap.servers"
,
_options
.
BrokerUrlList
}
};
var
config
=
new
Dictionary
<
string
,
object
>
{
{
"bootstrap.servers"
,
_options
.
BrokerUrlList
}
};
try
{
try
{
...
...
src/Cap.Consistency.Kafka/KafkaTopicAttribute.cs
View file @
3ebc726c
using
System
;
using
Cap.Consistency.Abstractions
;
using
System.Collections.Generic
;
using
System.Text
;
using
Cap.Consistency.Abstractions
;
namespace
Cap.Consistency.Kafka
namespace
Cap.Consistency.Kafka
{
{
...
...
src/Cap.Consistency.Kafka/Microsoft.Extensions.DependencyInjection/ConsistencyBuilderExtensions.cs
View file @
3ebc726c
using
System
;
using
Cap.Consistency.Consumer
;
using
System.Collections.Generic
;
using
System.Text
;
using
Cap.Consistency
;
using
Cap.Consistency.Consumer
;
using
Cap.Consistency.Kafka
;
using
Cap.Consistency.Kafka
;
using
Cap.Consistency.Producer
;
using
Cap.Consistency.Producer
;
...
@@ -11,13 +7,11 @@ namespace Microsoft.Extensions.DependencyInjection
...
@@ -11,13 +7,11 @@ namespace Microsoft.Extensions.DependencyInjection
public
static
class
ConsistencyBuilderExtensions
public
static
class
ConsistencyBuilderExtensions
{
{
public
static
ConsistencyBuilder
AddKafka
(
this
ConsistencyBuilder
builder
)
{
public
static
ConsistencyBuilder
AddKafka
(
this
ConsistencyBuilder
builder
)
{
builder
.
Services
.
AddSingleton
<
IConsumerClientFactory
,
KafkaConsumerClientFactory
>();
builder
.
Services
.
AddSingleton
<
IConsumerClientFactory
,
KafkaConsumerClientFactory
>();
builder
.
Services
.
AddTransient
<
IProducerClient
,
KafkaProducerClient
>();
builder
.
Services
.
AddTransient
<
IProducerClient
,
KafkaProducerClient
>();
return
builder
;
return
builder
;
}
}
}
}
}
}
\ No newline at end of file
src/Cap.Consistency.RabbitMQ/RabbitMQConsumerClient.cs
View file @
3ebc726c
using
System
;
using
System
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Cap.Consistency.Consumer
;
using
Cap.Consistency.Consumer
;
using
Cap.Consistency.Infrastructure
;
using
Cap.Consistency.Infrastructure
;
using
RabbitMQ.Client
;
using
RabbitMQ.Client
;
...
@@ -39,7 +38,6 @@ namespace Cap.Consistency.RabbitMQ
...
@@ -39,7 +38,6 @@ namespace Cap.Consistency.RabbitMQ
}
}
public
void
Listening
(
TimeSpan
timeout
)
{
public
void
Listening
(
TimeSpan
timeout
)
{
// Task.Delay(timeout).Wait();
// Task.Delay(timeout).Wait();
var
consumer
=
new
EventingBasicConsumer
(
_channel
);
var
consumer
=
new
EventingBasicConsumer
(
_channel
);
...
...
src/Cap.Consistency.RabbitMQ/RabbitMQConsumerClientFactory.cs
View file @
3ebc726c
using
System
;
using
Cap.Consistency.Consumer
;
using
System.Collections.Generic
;
using
System.Text
;
using
Cap.Consistency.Consumer
;
namespace
Cap.Consistency.RabbitMQ
namespace
Cap.Consistency.RabbitMQ
{
{
...
...
src/Cap.Consistency.RabbitMQ/RabbitMQProducerClient.cs
View file @
3ebc726c
using
System
;
using
System.Text
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Cap.Consistency.Infrastructure
;
using
Cap.Consistency.Infrastructure
;
using
Cap.Consistency.Producer
;
using
Cap.Consistency.Producer
;
...
@@ -12,7 +10,6 @@ namespace Cap.Consistency.RabbitMQ
...
@@ -12,7 +10,6 @@ namespace Cap.Consistency.RabbitMQ
{
{
public
class
RabbitMQProducerClient
:
IProducerClient
public
class
RabbitMQProducerClient
:
IProducerClient
{
{
private
readonly
ConsistencyOptions
_options
;
private
readonly
ConsistencyOptions
_options
;
private
readonly
ILogger
_logger
;
private
readonly
ILogger
_logger
;
...
@@ -28,7 +25,6 @@ namespace Cap.Consistency.RabbitMQ
...
@@ -28,7 +25,6 @@ namespace Cap.Consistency.RabbitMQ
channel
.
ExchangeDeclare
(
exchange
:
"topic_logs"
,
channel
.
ExchangeDeclare
(
exchange
:
"topic_logs"
,
type
:
"topic"
);
type
:
"topic"
);
var
body
=
Encoding
.
UTF8
.
GetBytes
(
content
);
var
body
=
Encoding
.
UTF8
.
GetBytes
(
content
);
channel
.
BasicPublish
(
exchange
:
"topic_logs"
,
channel
.
BasicPublish
(
exchange
:
"topic_logs"
,
routingKey
:
topic
,
routingKey
:
topic
,
...
...
src/Cap.Consistency/Consumer/IConsumerHandler.cs
View file @
3ebc726c
using
System
;
namespace
Cap.Consistency.Consumer
using
System.Collections.Generic
;
using
System.Text
;
using
Cap.Consistency.Infrastructure
;
namespace
Cap.Consistency.Consumer
{
{
public
interface
IConsumerHandler
:
ITopicRouteHandl
er
public
interface
IConsumerHandler
:
ITopicServ
er
{
{
}
}
}
}
\ No newline at end of file
test/Cap.Consistency.EntityFrameworkCore.Test/DefaultPocoTest.cs
View file @
3ebc726c
using
System
;
using
System.Threading.Tasks
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Cap.Consistency.Infrastructure
;
using
Cap.Consistency.Infrastructure
;
using
Cap.Consistency.Store
;
using
Cap.Consistency.Store
;
using
Microsoft.AspNetCore.Builder.Internal
;
using
Microsoft.AspNetCore.Builder.Internal
;
...
@@ -54,6 +51,5 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
...
@@ -54,6 +51,5 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
operateResult
=
await
messageManager
.
DeleteAsync
(
user
);
operateResult
=
await
messageManager
.
DeleteAsync
(
user
);
Assert
.
True
(
operateResult
.
Succeeded
);
Assert
.
True
(
operateResult
.
Succeeded
);
}
}
}
}
}
}
\ No newline at end of file
test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreTest.cs
View file @
3ebc726c
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Cap.Consistency.Infrastructure
;
using
Cap.Consistency.Infrastructure
;
...
@@ -27,7 +26,8 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
...
@@ -27,7 +26,8 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
public
class
ApplicationDbContext
:
ConsistencyDbContext
public
class
ApplicationDbContext
:
ConsistencyDbContext
{
{
public
ApplicationDbContext
(
DbContextOptions
<
ApplicationDbContext
>
options
)
:
base
(
options
)
{
}
public
ApplicationDbContext
(
DbContextOptions
<
ApplicationDbContext
>
options
)
:
base
(
options
)
{
}
}
}
[
ConditionalFact
]
[
ConditionalFact
]
...
@@ -75,7 +75,6 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
...
@@ -75,7 +75,6 @@ namespace Cap.Consistency.EntityFrameworkCore.Test
Assert
.
True
(
result
.
Succeeded
);
Assert
.
True
(
result
.
Succeeded
);
}
}
public
ConsistencyDbContext
CreateContext
(
bool
delete
=
false
)
{
public
ConsistencyDbContext
CreateContext
(
bool
delete
=
false
)
{
var
db
=
DbUtil
.
Create
<
ConsistencyDbContext
>(
_fixture
.
ConnectionString
);
var
db
=
DbUtil
.
Create
<
ConsistencyDbContext
>(
_fixture
.
ConnectionString
);
if
(
delete
)
{
if
(
delete
)
{
...
...
test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs
View file @
3ebc726c
...
@@ -3,7 +3,6 @@ using Cap.Consistency.Infrastructure;
...
@@ -3,7 +3,6 @@ using Cap.Consistency.Infrastructure;
using
Cap.Consistency.Store
;
using
Cap.Consistency.Store
;
using
Cap.Consistency.Test
;
using
Cap.Consistency.Test
;
using
Microsoft.AspNetCore.Testing
;
using
Microsoft.AspNetCore.Testing
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
Xunit
;
using
Xunit
;
...
...
test/Cap.Consistency.Test/ConsistencyMessageManagerTest.cs
View file @
3ebc726c
...
@@ -64,8 +64,7 @@ namespace Cap.Consistency.Test
...
@@ -64,8 +64,7 @@ namespace Cap.Consistency.Test
store
.
VerifyAll
();
store
.
VerifyAll
();
}
}
public
ConsistencyMessageManager
TestConsistencyMessageManager
(
IConsistencyMessageStore
store
=
null
)
public
ConsistencyMessageManager
TestConsistencyMessageManager
(
IConsistencyMessageStore
store
=
null
)
{
{
store
=
store
??
new
Mock
<
IConsistencyMessageStore
>().
Object
;
store
=
store
??
new
Mock
<
IConsistencyMessageStore
>().
Object
;
var
mockLogger
=
new
Mock
<
ILogger
<
ConsistencyMessageManager
>>().
Object
;
var
mockLogger
=
new
Mock
<
ILogger
<
ConsistencyMessageManager
>>().
Object
;
var
manager
=
new
ConsistencyMessageManager
(
store
,
null
,
mockLogger
);
var
manager
=
new
ConsistencyMessageManager
(
store
,
null
,
mockLogger
);
...
...
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