@@ -37,7 +37,7 @@ namespace DotNetCore.CAP.Dashboard | |||||
private class StubPage : RazorPage | private class StubPage : RazorPage | ||||
{ | { | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
} | } | ||||
} | } | ||||
@@ -61,7 +61,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -50,7 +50,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -33,7 +33,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -56,7 +56,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -56,7 +56,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -45,7 +45,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -33,7 +33,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -33,7 +33,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages | |||||
{ | { | ||||
#line hidden | #line hidden | ||||
public override void Execute() | |||||
protected override void Execute() | |||||
{ | { | ||||
@@ -3,6 +3,7 @@ using System.Diagnostics; | |||||
using System.Net; | using System.Net; | ||||
using System.Text; | using System.Text; | ||||
using DotNetCore.CAP.Dashboard.Monitoring; | using DotNetCore.CAP.Dashboard.Monitoring; | ||||
using DotNetCore.CAP.Internal; | |||||
using DotNetCore.CAP.NodeDiscovery; | using DotNetCore.CAP.NodeDiscovery; | ||||
using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||
@@ -20,16 +21,16 @@ namespace DotNetCore.CAP.Dashboard | |||||
Html = new HtmlHelper(this); | 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 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 | 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; } | internal IServiceProvider RequestServices { get; private set; } | ||||
public string RequestPath => Request.Path; | public string RequestPath => Request.Path; | ||||
/// <exclude /> | /// <exclude /> | ||||
public abstract void Execute(); | |||||
protected abstract void Execute(); | |||||
public string Query(string key) | |||||
protected string Query(string key) | |||||
{ | { | ||||
return Request.GetQuery(key); | return Request.GetQuery(key); | ||||
} | } | ||||
@@ -19,6 +19,10 @@ namespace DotNetCore.CAP | |||||
private readonly ILogger<DefaultBootstrapper> _logger; | private readonly ILogger<DefaultBootstrapper> _logger; | ||||
private Task _bootstrappingTask; | private Task _bootstrappingTask; | ||||
private IStorage Storage { get; } | |||||
private IEnumerable<IProcessingServer> Processors { get; } | |||||
public DefaultBootstrapper( | public DefaultBootstrapper( | ||||
ILogger<DefaultBootstrapper> logger, | ILogger<DefaultBootstrapper> logger, | ||||
IStorage storage, | IStorage storage, | ||||
@@ -45,10 +49,6 @@ namespace DotNetCore.CAP | |||||
}); | }); | ||||
} | } | ||||
protected IStorage Storage { get; } | |||||
protected IEnumerable<IProcessingServer> Processors { get; } | |||||
public Task BootstrapAsync() | public Task BootstrapAsync() | ||||
{ | { | ||||
return _bootstrappingTask = BootstrapTaskAsync(); | return _bootstrappingTask = BootstrapTaskAsync(); | ||||
@@ -60,10 +60,22 @@ namespace DotNetCore.CAP | |||||
if (_cts.IsCancellationRequested) return; | if (_cts.IsCancellationRequested) return; | ||||
await BootstrapCoreAsync(); | |||||
_appLifetime.ApplicationStopping.Register(() => | |||||
{ | |||||
foreach (var item in Processors) | |||||
item.Dispose(); | |||||
}); | |||||
if (_cts.IsCancellationRequested) return; | if (_cts.IsCancellationRequested) return; | ||||
await BootstrapCoreAsync(); | |||||
_ctsRegistration.Dispose(); | |||||
_cts.Dispose(); | |||||
} | |||||
protected virtual Task BootstrapCoreAsync() | |||||
{ | |||||
foreach (var item in Processors) | foreach (var item in Processors) | ||||
try | try | ||||
{ | { | ||||
@@ -71,20 +83,8 @@ namespace DotNetCore.CAP | |||||
} | } | ||||
catch (Exception ex) | 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; | return Task.CompletedTask; | ||||
} | } | ||||
} | } |
@@ -3,8 +3,14 @@ using DotNetCore.CAP.Models; | |||||
namespace DotNetCore.CAP | namespace DotNetCore.CAP | ||||
{ | { | ||||
/// <summary> | |||||
/// A callback that is sent to Productor after a successful consumer execution | |||||
/// </summary> | |||||
public interface ICallbackPublisher | public interface ICallbackPublisher | ||||
{ | { | ||||
/// <summary> | |||||
/// Publish a callback message | |||||
/// </summary> | |||||
Task PublishAsync(CapPublishedMessage obj); | Task PublishAsync(CapPublishedMessage obj); | ||||
} | } | ||||
} | } |
@@ -6,7 +6,7 @@ namespace DotNetCore.CAP | |||||
{ | { | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <summary> | /// <summary> | ||||
/// consumer client | |||||
/// Message queue consumer client | |||||
/// </summary> | /// </summary> | ||||
public interface IConsumerClient : IDisposable | public interface IConsumerClient : IDisposable | ||||
{ | { | ||||
@@ -3,7 +3,7 @@ using System.Collections.Generic; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Threading; | using System.Threading; | ||||
namespace DotNetCore.CAP | |||||
namespace DotNetCore.CAP.Internal | |||||
{ | { | ||||
#region Cache<T> class | #region Cache<T> class | ||||
@@ -15,7 +15,7 @@ namespace DotNetCore.CAP | |||||
/// </summary> | /// </summary> | ||||
// ReSharper disable once InheritdocConsiderUsage | // ReSharper disable once InheritdocConsiderUsage | ||||
// ReSharper disable once InconsistentNaming | // ReSharper disable once InconsistentNaming | ||||
public class Cache<K, T> : IDisposable | |||||
internal class Cache<K, T> : IDisposable | |||||
{ | { | ||||
#region Constructor and class members | #region Constructor and class members | ||||
@@ -328,7 +328,7 @@ namespace DotNetCore.CAP | |||||
/// instance. | /// instance. | ||||
/// The <c>.Global</c> member is lazy instanciated. | /// The <c>.Global</c> member is lazy instanciated. | ||||
/// </summary> | /// </summary> | ||||
public class CapCache : Cache<string, object> | |||||
internal class CapCache : Cache<string, object> | |||||
{ | { | ||||
#region Static Global Cache instance | #region Static Global Cache instance | ||||
@@ -21,11 +21,11 @@ namespace DotNetCore.CAP.Internal | |||||
/// <summary> | /// <summary> | ||||
/// a descriptor of consumer information need to be performed. | /// a descriptor of consumer information need to be performed. | ||||
/// </summary> | /// </summary> | ||||
public ConsumerExecutorDescriptor ConsumerDescriptor { get; set; } | |||||
public ConsumerExecutorDescriptor ConsumerDescriptor { get; } | |||||
/// <summary> | /// <summary> | ||||
/// consumer received message. | /// consumer received message. | ||||
/// </summary> | /// </summary> | ||||
public MessageContext DeliverMessage { get; set; } | |||||
public MessageContext DeliverMessage { get; } | |||||
} | } | ||||
} | } |
@@ -6,7 +6,7 @@ namespace DotNetCore.CAP | |||||
internal static class LoggerExtensions | internal static class LoggerExtensions | ||||
{ | { | ||||
private static readonly Action<ILogger, int, int, Exception> _serverStarting; | private static readonly Action<ILogger, int, int, Exception> _serverStarting; | ||||
private static readonly Action<ILogger, Exception> _serverStartingError; | |||||
private static readonly Action<ILogger, Exception> _processorsStartingError; | |||||
private static readonly Action<ILogger, Exception> _serverShuttingDown; | private static readonly Action<ILogger, Exception> _serverShuttingDown; | ||||
private static readonly Action<ILogger, string, Exception> _expectedOperationCanceledException; | private static readonly Action<ILogger, string, Exception> _expectedOperationCanceledException; | ||||
@@ -31,10 +31,10 @@ namespace DotNetCore.CAP | |||||
1, | 1, | ||||
"Starting the processing server. Detected {MachineProcessorCount} machine processor(s). Initiating {ProcessorCount} job processor(s)."); | "Starting the processing server. Detected {MachineProcessorCount} machine processor(s). Initiating {ProcessorCount} job processor(s)."); | ||||
_serverStartingError = LoggerMessage.Define( | |||||
_processorsStartingError = LoggerMessage.Define( | |||||
LogLevel.Error, | LogLevel.Error, | ||||
5, | 5, | ||||
"Starting the processing server throw an exception."); | |||||
"Starting the processors throw an exception."); | |||||
_serverShuttingDown = LoggerMessage.Define( | _serverShuttingDown = LoggerMessage.Define( | ||||
LogLevel.Debug, | LogLevel.Debug, | ||||
@@ -149,9 +149,9 @@ namespace DotNetCore.CAP | |||||
_serverStarting(logger, machineProcessorCount, processorCount, null); | _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) | public static void ServerShuttingDown(this ILogger logger) | ||||
@@ -3,6 +3,7 @@ using System.Collections.Generic; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using Consul; | using Consul; | ||||
using DotNetCore.CAP.Internal; | |||||
using Microsoft.Extensions.Logging; | using Microsoft.Extensions.Logging; | ||||
namespace DotNetCore.CAP.NodeDiscovery | namespace DotNetCore.CAP.NodeDiscovery | ||||
@@ -90,7 +91,7 @@ namespace DotNetCore.CAP.NodeDiscovery | |||||
} | } | ||||
} | } | ||||
public void InitClient() | |||||
private void InitClient() | |||||
{ | { | ||||
_consul = new ConsulClient(config => | _consul = new ConsulClient(config => | ||||
{ | { | ||||