Commit 9edc31b0 authored by Savorboard's avatar Savorboard

refactor.

parent 9b7c3f56
...@@ -112,7 +112,7 @@ namespace DotNetCore.CAP.Abstractions ...@@ -112,7 +112,7 @@ namespace DotNetCore.CAP.Abstractions
"If you are using the EntityFramework, you do not need to use this overloaded."); "If you are using the EntityFramework, you do not need to use this overloaded.");
} }
private async Task PublishWithTransAsync(string name, string content) private Task PublishWithTransAsync(string name, string content)
{ {
var message = new CapPublishedMessage var message = new CapPublishedMessage
{ {
...@@ -121,11 +121,13 @@ namespace DotNetCore.CAP.Abstractions ...@@ -121,11 +121,13 @@ namespace DotNetCore.CAP.Abstractions
StatusName = StatusName.Scheduled StatusName = StatusName.Scheduled
}; };
await ExecuteAsync(DbConnection, DbTransaction, message); ExecuteAsync(DbConnection, DbTransaction, message);
ClosedCap(); ClosedCap();
PublishQueuer.PulseEvent.Set(); PublishQueuer.PulseEvent.Set();
return Task.CompletedTask;
} }
private void PublishWithTrans(string name, string content) private void PublishWithTrans(string name, string content)
......
...@@ -4,12 +4,12 @@ using System.Threading; ...@@ -4,12 +4,12 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace DotNetCore.CAP namespace DotNetCore.CAP
{ {
/// <inheritdoc />
/// <summary> /// <summary>
/// Default implement of <see cref="IBootstrapper" />. /// Default implement of <see cref="T:DotNetCore.CAP.IBootstrapper" />.
/// </summary> /// </summary>
internal class DefaultBootstrapper : IBootstrapper internal class DefaultBootstrapper : IBootstrapper
{ {
...@@ -21,16 +21,14 @@ namespace DotNetCore.CAP ...@@ -21,16 +21,14 @@ namespace DotNetCore.CAP
public DefaultBootstrapper( public DefaultBootstrapper(
ILogger<DefaultBootstrapper> logger, ILogger<DefaultBootstrapper> logger,
IOptions<CapOptions> options,
IStorage storage, IStorage storage,
IApplicationLifetime appLifetime, IApplicationLifetime appLifetime,
IEnumerable<IProcessingServer> servers) IEnumerable<IProcessingServer> processors)
{ {
_logger = logger; _logger = logger;
_appLifetime = appLifetime; _appLifetime = appLifetime;
Options = options.Value;
Storage = storage; Storage = storage;
Servers = servers; Processors = processors;
_cts = new CancellationTokenSource(); _cts = new CancellationTokenSource();
_ctsRegistration = appLifetime.ApplicationStopping.Register(() => _ctsRegistration = appLifetime.ApplicationStopping.Register(() =>
...@@ -47,11 +45,9 @@ namespace DotNetCore.CAP ...@@ -47,11 +45,9 @@ namespace DotNetCore.CAP
}); });
} }
protected CapOptions Options { get; }
protected IStorage Storage { get; } protected IStorage Storage { get; }
protected IEnumerable<IProcessingServer> Servers { get; } protected IEnumerable<IProcessingServer> Processors { get; }
public Task BootstrapAsync() public Task BootstrapAsync()
{ {
...@@ -68,7 +64,7 @@ namespace DotNetCore.CAP ...@@ -68,7 +64,7 @@ namespace DotNetCore.CAP
if (_cts.IsCancellationRequested) return; if (_cts.IsCancellationRequested) return;
foreach (var item in Servers) foreach (var item in Processors)
try try
{ {
item.Start(); item.Start();
...@@ -86,7 +82,7 @@ namespace DotNetCore.CAP ...@@ -86,7 +82,7 @@ namespace DotNetCore.CAP
{ {
_appLifetime.ApplicationStopping.Register(() => _appLifetime.ApplicationStopping.Register(() =>
{ {
foreach (var item in Servers) foreach (var item in Processors)
item.Dispose(); item.Dispose();
}); });
return Task.CompletedTask; return Task.CompletedTask;
......
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