diff --git a/src/DotNetCore.CAP/Dashboard/JsonStats.cs b/src/DotNetCore.CAP/Dashboard/JsonStats.cs index 78ad871..fbc9f2c 100644 --- a/src/DotNetCore.CAP/Dashboard/JsonStats.cs +++ b/src/DotNetCore.CAP/Dashboard/JsonStats.cs @@ -37,7 +37,7 @@ namespace DotNetCore.CAP.Dashboard private class StubPage : RazorPage { - public override void Execute() + protected override void Execute() { } } diff --git a/src/DotNetCore.CAP/Dashboard/Pages/HomePage.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/HomePage.generated.cs index 74a5087..d9b3137 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/HomePage.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/HomePage.generated.cs @@ -61,7 +61,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/LayoutPage.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/LayoutPage.generated.cs index 5677e12..374062b 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/LayoutPage.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/LayoutPage.generated.cs @@ -50,7 +50,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/NodePage.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/NodePage.generated.cs index bbd85bc..9b205b1 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/NodePage.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/NodePage.generated.cs @@ -33,7 +33,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/PublishedPage.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/PublishedPage.generated.cs index 667154b..9514d49 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/PublishedPage.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/PublishedPage.generated.cs @@ -56,7 +56,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/ReceivedPage.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/ReceivedPage.generated.cs index fb955a8..77e480e 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/ReceivedPage.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/ReceivedPage.generated.cs @@ -56,7 +56,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.generated.cs index 9e1aa78..ebec86b 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.generated.cs @@ -45,7 +45,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/_BlockMetric.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/_BlockMetric.generated.cs index e8ad9cc..e29de0b 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/_BlockMetric.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/_BlockMetric.generated.cs @@ -33,7 +33,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/_Breadcrumbs.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/_Breadcrumbs.generated.cs index 8e10a8a..ce63c17 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/_Breadcrumbs.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/_Breadcrumbs.generated.cs @@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/_InlineMetric.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/_InlineMetric.generated.cs index e6f9833..1f9fcd3 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/_InlineMetric.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/_InlineMetric.generated.cs @@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/_Navigation.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/_Navigation.generated.cs index 4f08933..273d9eb 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/_Navigation.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/_Navigation.generated.cs @@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/_Paginator.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/_Paginator.generated.cs index 020372e..21fdf9c 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/_Paginator.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/_Paginator.generated.cs @@ -33,7 +33,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/_PerPageSelector.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/_PerPageSelector.generated.cs index 57428c5..931ab0d 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/_PerPageSelector.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/_PerPageSelector.generated.cs @@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/Pages/_SidebarMenu.generated.cs b/src/DotNetCore.CAP/Dashboard/Pages/_SidebarMenu.generated.cs index 98cd08f..ca8e4ce 100644 --- a/src/DotNetCore.CAP/Dashboard/Pages/_SidebarMenu.generated.cs +++ b/src/DotNetCore.CAP/Dashboard/Pages/_SidebarMenu.generated.cs @@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - public override void Execute() + protected override void Execute() { diff --git a/src/DotNetCore.CAP/Dashboard/RazorPage.cs b/src/DotNetCore.CAP/Dashboard/RazorPage.cs index a78960c..93b3425 100644 --- a/src/DotNetCore.CAP/Dashboard/RazorPage.cs +++ b/src/DotNetCore.CAP/Dashboard/RazorPage.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Net; using System.Text; using DotNetCore.CAP.Dashboard.Monitoring; +using DotNetCore.CAP.Internal; using DotNetCore.CAP.NodeDiscovery; using Microsoft.Extensions.DependencyInjection; @@ -20,16 +21,16 @@ namespace DotNetCore.CAP.Dashboard Html = new HtmlHelper(this); } - public RazorPage Layout { get; protected set; } - public HtmlHelper Html { get; } + protected RazorPage Layout { get; set; } + protected HtmlHelper Html { get; } public UrlHelper Url { get; private set; } - public IStorage Storage { get; internal set; } - public string AppPath { get; internal set; } - public string NodeName { get; internal set; } + protected IStorage Storage { get; set; } + protected string AppPath { get; set; } + protected string NodeName { get; set; } - public int StatsPollingInterval { get; internal set; } - public Stopwatch GenerationTime { get; private set; } + protected int StatsPollingInterval { get; set; } + protected Stopwatch GenerationTime { get; private set; } public StatisticsDto Statistics { @@ -40,16 +41,16 @@ namespace DotNetCore.CAP.Dashboard } } - protected DashboardRequest Request { private get; set; } - protected DashboardResponse Response { private get; set; } + private DashboardRequest Request { get; set; } + private DashboardResponse Response { get; set; } internal IServiceProvider RequestServices { get; private set; } public string RequestPath => Request.Path; /// - public abstract void Execute(); + protected abstract void Execute(); - public string Query(string key) + protected string Query(string key) { return Request.GetQuery(key); } diff --git a/src/DotNetCore.CAP/IBootstrapper.Default.cs b/src/DotNetCore.CAP/IBootstrapper.Default.cs index 8359211..64f298c 100644 --- a/src/DotNetCore.CAP/IBootstrapper.Default.cs +++ b/src/DotNetCore.CAP/IBootstrapper.Default.cs @@ -19,6 +19,10 @@ namespace DotNetCore.CAP private readonly ILogger _logger; private Task _bootstrappingTask; + private IStorage Storage { get; } + + private IEnumerable Processors { get; } + public DefaultBootstrapper( ILogger logger, IStorage storage, @@ -45,10 +49,6 @@ namespace DotNetCore.CAP }); } - protected IStorage Storage { get; } - - protected IEnumerable Processors { get; } - public Task BootstrapAsync() { return _bootstrappingTask = BootstrapTaskAsync(); @@ -60,10 +60,22 @@ namespace DotNetCore.CAP if (_cts.IsCancellationRequested) return; - await BootstrapCoreAsync(); + _appLifetime.ApplicationStopping.Register(() => + { + foreach (var item in Processors) + item.Dispose(); + }); if (_cts.IsCancellationRequested) return; + await BootstrapCoreAsync(); + + _ctsRegistration.Dispose(); + _cts.Dispose(); + } + + protected virtual Task BootstrapCoreAsync() + { foreach (var item in Processors) try { @@ -71,20 +83,8 @@ namespace DotNetCore.CAP } catch (Exception ex) { - _logger.ServerStartedError(ex); + _logger.ProcessorsStartedError(ex); } - - _ctsRegistration.Dispose(); - _cts.Dispose(); - } - - public virtual Task BootstrapCoreAsync() - { - _appLifetime.ApplicationStopping.Register(() => - { - foreach (var item in Processors) - item.Dispose(); - }); return Task.CompletedTask; } } diff --git a/src/DotNetCore.CAP/ICallbackPublisher.cs b/src/DotNetCore.CAP/ICallbackPublisher.cs index ae30487..37170b9 100644 --- a/src/DotNetCore.CAP/ICallbackPublisher.cs +++ b/src/DotNetCore.CAP/ICallbackPublisher.cs @@ -3,8 +3,14 @@ using DotNetCore.CAP.Models; namespace DotNetCore.CAP { + /// + /// A callback that is sent to Productor after a successful consumer execution + /// public interface ICallbackPublisher { + /// + /// Publish a callback message + /// Task PublishAsync(CapPublishedMessage obj); } } \ No newline at end of file diff --git a/src/DotNetCore.CAP/IConsumerClient.cs b/src/DotNetCore.CAP/IConsumerClient.cs index dcf8e5f..89d199c 100644 --- a/src/DotNetCore.CAP/IConsumerClient.cs +++ b/src/DotNetCore.CAP/IConsumerClient.cs @@ -6,7 +6,7 @@ namespace DotNetCore.CAP { /// /// - /// consumer client + /// Message queue consumer client /// public interface IConsumerClient : IDisposable { diff --git a/src/DotNetCore.CAP/CapCache.cs b/src/DotNetCore.CAP/Internal/CapCache.cs similarity index 98% rename from src/DotNetCore.CAP/CapCache.cs rename to src/DotNetCore.CAP/Internal/CapCache.cs index 8bb55f6..d9826db 100644 --- a/src/DotNetCore.CAP/CapCache.cs +++ b/src/DotNetCore.CAP/Internal/CapCache.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Internal { #region Cache class @@ -15,7 +15,7 @@ namespace DotNetCore.CAP /// // ReSharper disable once InheritdocConsiderUsage // ReSharper disable once InconsistentNaming - public class Cache : IDisposable + internal class Cache : IDisposable { #region Constructor and class members @@ -328,7 +328,7 @@ namespace DotNetCore.CAP /// instance. /// The .Global member is lazy instanciated. /// - public class CapCache : Cache + internal class CapCache : Cache { #region Static Global Cache instance diff --git a/src/DotNetCore.CAP/Internal/ConsumerContext.cs b/src/DotNetCore.CAP/Internal/ConsumerContext.cs index 288b629..cafd33f 100644 --- a/src/DotNetCore.CAP/Internal/ConsumerContext.cs +++ b/src/DotNetCore.CAP/Internal/ConsumerContext.cs @@ -21,11 +21,11 @@ namespace DotNetCore.CAP.Internal /// /// a descriptor of consumer information need to be performed. /// - public ConsumerExecutorDescriptor ConsumerDescriptor { get; set; } + public ConsumerExecutorDescriptor ConsumerDescriptor { get; } /// /// consumer received message. /// - public MessageContext DeliverMessage { get; set; } + public MessageContext DeliverMessage { get; } } } \ No newline at end of file diff --git a/src/DotNetCore.CAP/LoggerExtensions.cs b/src/DotNetCore.CAP/LoggerExtensions.cs index 49fe4a8..1352fda 100644 --- a/src/DotNetCore.CAP/LoggerExtensions.cs +++ b/src/DotNetCore.CAP/LoggerExtensions.cs @@ -6,7 +6,7 @@ namespace DotNetCore.CAP internal static class LoggerExtensions { private static readonly Action _serverStarting; - private static readonly Action _serverStartingError; + private static readonly Action _processorsStartingError; private static readonly Action _serverShuttingDown; private static readonly Action _expectedOperationCanceledException; @@ -31,10 +31,10 @@ namespace DotNetCore.CAP 1, "Starting the processing server. Detected {MachineProcessorCount} machine processor(s). Initiating {ProcessorCount} job processor(s)."); - _serverStartingError = LoggerMessage.Define( + _processorsStartingError = LoggerMessage.Define( LogLevel.Error, 5, - "Starting the processing server throw an exception."); + "Starting the processors throw an exception."); _serverShuttingDown = LoggerMessage.Define( LogLevel.Debug, @@ -149,9 +149,9 @@ namespace DotNetCore.CAP _serverStarting(logger, machineProcessorCount, processorCount, null); } - public static void ServerStartedError(this ILogger logger, Exception ex) + public static void ProcessorsStartedError(this ILogger logger, Exception ex) { - _serverStartingError(logger, ex); + _processorsStartingError(logger, ex); } public static void ServerShuttingDown(this ILogger logger) diff --git a/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs b/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs index 6234c9c..6f5cc59 100644 --- a/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs +++ b/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Consul; +using DotNetCore.CAP.Internal; using Microsoft.Extensions.Logging; namespace DotNetCore.CAP.NodeDiscovery @@ -90,7 +91,7 @@ namespace DotNetCore.CAP.NodeDiscovery } } - public void InitClient() + private void InitClient() { _consul = new ConsulClient(config => {