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
d5b1e569
Commit
d5b1e569
authored
Dec 15, 2016
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename class
parent
1df2451c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
23 deletions
+40
-23
.gitignore
.gitignore
+2
-1
Cap.sln
Cap.sln
+7
-0
BuilderExtensions.cs
src/Cap.Consistency/BuilderExtensions.cs
+3
-3
ConsistencyBuilder.cs
src/Cap.Consistency/ConsistencyBuilder.cs
+11
-9
ConsistencyMarkerService.cs
src/Cap.Consistency/ConsistencyMarkerService.cs
+7
-0
ConsistencyMessageManager.cs
src/Cap.Consistency/ConsistencyMessageManager.cs
+5
-5
IConsistencyMessageStore.cs
src/Cap.Consistency/IConsistencyMessageStore.cs
+2
-2
ServiceCollectionExtensions.cs
src/Cap.Consistency/ServiceCollectionExtensions.cs
+3
-3
No files found.
.gitignore
View file @
d5b1e569
...
@@ -28,3 +28,4 @@ project.lock.json
...
@@ -28,3 +28,4 @@ project.lock.json
.vs
.vs
.build/
.build/
.testPublish/
.testPublish/
/src/Cap.Consistency/obj/Debug/netstandard1.6
Cap.sln
View file @
d5b1e569
...
@@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
...
@@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Cap.Consistency", "src\Cap.Consistency\Cap.Consistency.xproj", "{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}"
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Cap.Consistency", "src\Cap.Consistency\Cap.Consistency.xproj", "{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}"
EndProject
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Cap.Consistency.Test", "test\Cap.Consistency.Test\Cap.Consistency.Test.xproj", "{3A444CF8-1611-407F-8D32-5D0CDC3DD49D}"
EndProject
Global
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Any CPU = Debug|Any CPU
...
@@ -24,11 +26,16 @@ Global
...
@@ -24,11 +26,16 @@ Global
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}.Release|Any CPU.Build.0 = Release|Any CPU
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}.Release|Any CPU.Build.0 = Release|Any CPU
{3A444CF8-1611-407F-8D32-5D0CDC3DD49D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A444CF8-1611-407F-8D32-5D0CDC3DD49D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A444CF8-1611-407F-8D32-5D0CDC3DD49D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A444CF8-1611-407F-8D32-5D0CDC3DD49D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
HideSolutionNode = FALSE
EndGlobalSection
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
GlobalSection(NestedProjects) = preSolution
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4}
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4}
{3A444CF8-1611-407F-8D32-5D0CDC3DD49D} = {C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0}
EndGlobalSection
EndGlobalSection
EndGlobal
EndGlobal
src/Cap.Consistency/BuilderExtensions.cs
View file @
d5b1e569
...
@@ -6,12 +6,12 @@ using System;
...
@@ -6,12 +6,12 @@ using System;
namespace
Microsoft.AspNetCore.Builder
namespace
Microsoft.AspNetCore.Builder
{
{
/// <summary>
/// <summary>
///
KafkaConso
stence extensions for <see cref="IApplicationBuilder"/>
///
Consi
stence extensions for <see cref="IApplicationBuilder"/>
/// </summary>
/// </summary>
public
static
class
BuilderExtensions
public
static
class
BuilderExtensions
{
{
/// <summary>
/// <summary>
/// Enables
Kafka
Consistence for the current application
/// Enables Consistence for the current application
/// </summary>
/// </summary>
/// <param name="app">The <see cref="IApplicationBuilder"/> instance this method extends.</param>
/// <param name="app">The <see cref="IApplicationBuilder"/> instance this method extends.</param>
/// <returns>The <see cref="IApplicationBuilder"/> instance this method extends.</returns>
/// <returns>The <see cref="IApplicationBuilder"/> instance this method extends.</returns>
...
@@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Builder
...
@@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Builder
throw
new
ArgumentNullException
(
nameof
(
app
));
throw
new
ArgumentNullException
(
nameof
(
app
));
}
}
var
marker
=
app
.
ApplicationServices
.
GetService
<
KafkaConsistence
MarkerService
>();
var
marker
=
app
.
ApplicationServices
.
GetService
<
Consistency
MarkerService
>();
if
(
marker
==
null
)
{
if
(
marker
==
null
)
{
throw
new
InvalidOperationException
(
"AddKafkaConsistence must be called on the service collection."
);
throw
new
InvalidOperationException
(
"AddKafkaConsistence must be called on the service collection."
);
}
}
...
...
src/Cap.Consistency/Consistenc
e
Builder.cs
→
src/Cap.Consistency/Consistenc
y
Builder.cs
View file @
d5b1e569
...
@@ -3,15 +3,17 @@ using System;
...
@@ -3,15 +3,17 @@ using System;
namespace
Cap.Consistency
namespace
Cap.Consistency
{
{
/// <summary>
public
class
ConsistenceBuilder
/// Helper functions for configuring consistency services.
/// </summary>
public
class
ConsistencyBuilder
{
{
/// <summary>
/// <summary>
/// Creates a new instance of <see cref="Consistenc
e
Builder"/>.
/// Creates a new instance of <see cref="Consistenc
y
Builder"/>.
/// </summary>
/// </summary>
/// <param name="message">The <see cref="Type"/> to use for the message.</param>
/// <param name="message">The <see cref="Type"/> to use for the message.</param>
/// <param name="service">The <see cref="IServiceCollection"/> to attach to.</param>
/// <param name="service">The <see cref="IServiceCollection"/> to attach to.</param>
public
Consistenc
e
Builder
(
Type
message
,
IServiceCollection
service
)
{
public
Consistenc
y
Builder
(
Type
message
,
IServiceCollection
service
)
{
MessageType
=
message
;
MessageType
=
message
;
Services
=
service
;
Services
=
service
;
}
}
...
@@ -33,15 +35,15 @@ namespace Cap.Consistency
...
@@ -33,15 +35,15 @@ namespace Cap.Consistency
public
Type
MessageType
{
get
;
private
set
;
}
public
Type
MessageType
{
get
;
private
set
;
}
/// <summary>
/// <summary>
/// Adds a <see cref="IConsisten
t
MessageStore{TMessage}"/> for the <seealso cref="MessageType"/>.
/// Adds a <see cref="IConsisten
cy
MessageStore{TMessage}"/> for the <seealso cref="MessageType"/>.
/// </summary>
/// </summary>
/// <typeparam name="T">The role type held in the store.</typeparam>
/// <typeparam name="T">The role type held in the store.</typeparam>
/// <returns>The current <see cref="Consistenc
e
Builder"/> instance.</returns>
/// <returns>The current <see cref="Consistenc
y
Builder"/> instance.</returns>
public
virtual
Consistenc
e
Builder
AddMessageStore
<
T
>()
where
T
:
class
{
public
virtual
Consistenc
y
Builder
AddMessageStore
<
T
>()
where
T
:
class
{
return
AddScoped
(
typeof
(
IConsisten
t
MessageStore
<>).
MakeGenericType
(
MessageType
),
typeof
(
T
));
return
AddScoped
(
typeof
(
IConsisten
cy
MessageStore
<>).
MakeGenericType
(
MessageType
),
typeof
(
T
));
}
}
private
Consistenc
e
Builder
AddScoped
(
Type
serviceType
,
Type
concreteType
)
{
private
Consistenc
y
Builder
AddScoped
(
Type
serviceType
,
Type
concreteType
)
{
Services
.
AddScoped
(
serviceType
,
concreteType
);
Services
.
AddScoped
(
serviceType
,
concreteType
);
return
this
;
return
this
;
}
}
...
...
src/Cap.Consistency/
KafkaConsistence
MarkerService.cs
→
src/Cap.Consistency/
Consistency
MarkerService.cs
View file @
d5b1e569
namespace
Cap.Consistency
namespace
Cap.Consistency
{
{
/// <summary>
/// <summary>
/// Used to verify
KafkaConsisten
ce was called on a ServiceCollection
/// Used to verify
Consistency servi
ce was called on a ServiceCollection
/// </summary>
/// </summary>
public
class
KafkaConsistence
MarkerService
{
}
public
class
Consistency
MarkerService
{
}
}
}
\ No newline at end of file
src/Cap.Consistency/Consisten
t
MessageManager.cs
→
src/Cap.Consistency/Consisten
cy
MessageManager.cs
View file @
d5b1e569
...
@@ -11,21 +11,21 @@ namespace Cap.Consistency
...
@@ -11,21 +11,21 @@ namespace Cap.Consistency
/// Provides the APIs for managing message in a persistence store.
/// Provides the APIs for managing message in a persistence store.
/// </summary>
/// </summary>
/// <typeparam name="TMessage">The type encapsulating a message.</typeparam>
/// <typeparam name="TMessage">The type encapsulating a message.</typeparam>
public
class
Consisten
t
MessageManager
<
TMessage
>
:
IDisposable
where
TMessage
:
class
public
class
Consisten
cy
MessageManager
<
TMessage
>
:
IDisposable
where
TMessage
:
class
{
{
private
bool
_disposed
;
private
bool
_disposed
;
private
readonly
HttpContext
_context
;
private
readonly
HttpContext
_context
;
private
CancellationToken
CancellationToken
=>
_context
?.
RequestAborted
??
CancellationToken
.
None
;
private
CancellationToken
CancellationToken
=>
_context
?.
RequestAborted
??
CancellationToken
.
None
;
/// <summary>
/// <summary>
/// Constructs a new instance of <see cref="Consisten
t
MessageManager{TMessage}"/>.
/// Constructs a new instance of <see cref="Consisten
cy
MessageManager{TMessage}"/>.
/// </summary>
/// </summary>
/// <param name="store">The persistence store the manager will operate over.</param>
/// <param name="store">The persistence store the manager will operate over.</param>
/// <param name="services">The <see cref="IServiceProvider"/> used to resolve services.</param>
/// <param name="services">The <see cref="IServiceProvider"/> used to resolve services.</param>
/// <param name="logger">The logger used to log messages, warnings and errors.</param>
/// <param name="logger">The logger used to log messages, warnings and errors.</param>
public
Consisten
tMessageManager
(
IConsistent
MessageStore
<
TMessage
>
store
,
public
Consisten
cyMessageManager
(
IConsistency
MessageStore
<
TMessage
>
store
,
IServiceProvider
services
,
IServiceProvider
services
,
ILogger
<
Consisten
t
MessageManager
<
TMessage
>>
logger
)
{
ILogger
<
Consisten
cy
MessageManager
<
TMessage
>>
logger
)
{
if
(
store
==
null
)
{
if
(
store
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
store
));
throw
new
ArgumentNullException
(
nameof
(
store
));
}
}
...
@@ -42,7 +42,7 @@ namespace Cap.Consistency
...
@@ -42,7 +42,7 @@ namespace Cap.Consistency
/// Gets or sets the persistence store the manager operates over.
/// Gets or sets the persistence store the manager operates over.
/// </summary>
/// </summary>
/// <value>The persistence store the manager operates over.</value>
/// <value>The persistence store the manager operates over.</value>
protected
internal
IConsisten
t
MessageStore
<
TMessage
>
Store
{
get
;
set
;
}
protected
internal
IConsisten
cy
MessageStore
<
TMessage
>
Store
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Gets the <see cref="ILogger"/> used to log messages from the manager.
/// Gets the <see cref="ILogger"/> used to log messages from the manager.
...
...
src/Cap.Consistency/IConsisten
t
MessageStore.cs
→
src/Cap.Consistency/IConsisten
cy
MessageStore.cs
View file @
d5b1e569
...
@@ -5,10 +5,10 @@ using System.Threading.Tasks;
...
@@ -5,10 +5,10 @@ using System.Threading.Tasks;
namespace
Cap.Consistency
namespace
Cap.Consistency
{
{
/// <summary>
/// <summary>
/// Provides an abstraction for a store which manages
kafka
consistent message.
/// Provides an abstraction for a store which manages consistent message.
/// </summary>
/// </summary>
/// <typeparam name="TMessage"></typeparam>
/// <typeparam name="TMessage"></typeparam>
public
interface
IConsisten
t
MessageStore
<
TMessage
>
:
IDisposable
where
TMessage
:
class
public
interface
IConsisten
cy
MessageStore
<
TMessage
>
:
IDisposable
where
TMessage
:
class
{
{
/// <summary>
/// <summary>
/// Finds and returns a message, if any, who has the specified <paramref name="messageId"/>.
/// Finds and returns a message, if any, who has the specified <paramref name="messageId"/>.
...
...
src/Cap.Consistency/ServiceCollectionExtensions.cs
View file @
d5b1e569
...
@@ -15,12 +15,12 @@ namespace Microsoft.Extensions.DependencyInjection
...
@@ -15,12 +15,12 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
/// </summary>
/// <param name="services">The services available in the application.</param>
/// <param name="services">The services available in the application.</param>
/// <returns>An <see cref="IServiceCollection"/> for application services.</returns>
/// <returns>An <see cref="IServiceCollection"/> for application services.</returns>
public
static
Consistenc
e
Builder
AddKafkaConsistence
<
TMessage
>(
this
IServiceCollection
services
)
public
static
Consistenc
y
Builder
AddKafkaConsistence
<
TMessage
>(
this
IServiceCollection
services
)
where
TMessage
:
class
{
where
TMessage
:
class
{
services
.
TryAddSingleton
<
KafkaConsistence
MarkerService
>();
services
.
TryAddSingleton
<
Consistency
MarkerService
>();
return
new
Consistenc
e
Builder
(
typeof
(
TMessage
),
services
);
return
new
Consistenc
y
Builder
(
typeof
(
TMessage
),
services
);
}
}
}
}
}
}
\ 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