Commit d5b1e569 authored by yangxiaodong's avatar yangxiaodong

rename class

parent 1df2451c
...@@ -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
...@@ -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
...@@ -6,12 +6,12 @@ using System; ...@@ -6,12 +6,12 @@ using System;
namespace Microsoft.AspNetCore.Builder namespace Microsoft.AspNetCore.Builder
{ {
/// <summary> /// <summary>
/// KafkaConsostence extensions for <see cref="IApplicationBuilder"/> /// Consistence extensions for <see cref="IApplicationBuilder"/>
/// </summary> /// </summary>
public static class BuilderExtensions public static class BuilderExtensions
{ {
/// <summary> /// <summary>
/// Enables KafkaConsistence 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<KafkaConsistenceMarkerService>(); var marker = app.ApplicationServices.GetService<ConsistencyMarkerService>();
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.");
} }
......
...@@ -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="ConsistenceBuilder"/>. /// Creates a new instance of <see cref="ConsistencyBuilder"/>.
/// </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 ConsistenceBuilder(Type message, IServiceCollection service) { public ConsistencyBuilder(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="IConsistentMessageStore{TMessage}"/> for the <seealso cref="MessageType"/>. /// Adds a <see cref="IConsistencyMessageStore{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="ConsistenceBuilder"/> instance.</returns> /// <returns>The current <see cref="ConsistencyBuilder"/> instance.</returns>
public virtual ConsistenceBuilder AddMessageStore<T>() where T : class { public virtual ConsistencyBuilder AddMessageStore<T>() where T : class {
return AddScoped(typeof(IConsistentMessageStore<>).MakeGenericType(MessageType), typeof(T)); return AddScoped(typeof(IConsistencyMessageStore<>).MakeGenericType(MessageType), typeof(T));
} }
private ConsistenceBuilder AddScoped(Type serviceType, Type concreteType) { private ConsistencyBuilder AddScoped(Type serviceType, Type concreteType) {
Services.AddScoped(serviceType, concreteType); Services.AddScoped(serviceType, concreteType);
return this; return this;
} }
......
namespace Cap.Consistency namespace Cap.Consistency
{ {
/// <summary> /// <summary>
/// Used to verify KafkaConsistence was called on a ServiceCollection /// Used to verify Consistency service was called on a ServiceCollection
/// </summary> /// </summary>
public class KafkaConsistenceMarkerService { } public class ConsistencyMarkerService { }
} }
\ No newline at end of file
...@@ -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 ConsistentMessageManager<TMessage> : IDisposable where TMessage : class public class ConsistencyMessageManager<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="ConsistentMessageManager{TMessage}"/>. /// Constructs a new instance of <see cref="ConsistencyMessageManager{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 ConsistentMessageManager(IConsistentMessageStore<TMessage> store, public ConsistencyMessageManager(IConsistencyMessageStore<TMessage> store,
IServiceProvider services, IServiceProvider services,
ILogger<ConsistentMessageManager<TMessage>> logger) { ILogger<ConsistencyMessageManager<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 IConsistentMessageStore<TMessage> Store { get; set; } protected internal IConsistencyMessageStore<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.
......
...@@ -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 IConsistentMessageStore<TMessage> : IDisposable where TMessage : class public interface IConsistencyMessageStore<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"/>.
......
...@@ -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 ConsistenceBuilder AddKafkaConsistence<TMessage>(this IServiceCollection services) public static ConsistencyBuilder AddKafkaConsistence<TMessage>(this IServiceCollection services)
where TMessage : class { where TMessage : class {
services.TryAddSingleton<KafkaConsistenceMarkerService>(); services.TryAddSingleton<ConsistencyMarkerService>();
return new ConsistenceBuilder(typeof(TMessage), services); return new ConsistencyBuilder(typeof(TMessage), services);
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment